Mujin Programming Challenge 2017

Submission #1319994

Source codeソースコード

#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<sstream>
#include<numeric>
#include<iostream>
#include<algorithm>
#include<functional>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> Vi;
typedef pair<int,int> pii;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=1000+19;
const int oo=(1<<30)-1;

char s[N][N];
int sum[N][N];
int n,tmp,res=oo;

int cal(int X1,int Y1,int X2,int Y2){
	return sum[X2][Y2]-sum[X2][Y1-1]-sum[X1-1][Y2]+sum[X1-1][Y1-1];
}

int main(){
	n=IN();
	For(i,1,n+1) scanf("%s",s[i]+1);
	For(i,1,n+1) For(j,1,n+1){
		sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+(s[i][j]=='#');
	}
	if (!sum[n][n]) return puts("-1"),0;
	For(i,1,n+1) if (cal(1,i,n,i)==n) tmp++;
	For(i,1,n+1){
		res=min(res,n-cal(i,1,i,n)+!cal(1,i,n,i)+n-tmp);
	}
	printf("%d\n",res);
}

Submission

Task問題 B - Row to Column
User nameユーザ名 rxdoi
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 1300
Source lengthソースコード長 1329 Byte
File nameファイル名
Exec time実行時間 4 ms
Memory usageメモリ使用量 4736 KB

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:52:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
For(i,1,n+1) scanf("%s",s[i]+1);
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - 0_00.txt,0_01.txt,0_02.txt,0_03.txt,0_04.txt
Subtask 300 / 300 0_00.txt,0_01.txt,0_02.txt,0_03.txt,0_04.txt,1_00.txt,1_01.txt,1_02.txt,1_03.txt,1_04.txt,1_05.txt,1_06.txt,1_07.txt,1_08.txt,1_09.txt,1_10.txt,1_11.txt,1_12.txt,1_13.txt,1_14.txt
All 1000 / 1000 0_00.txt,0_01.txt,0_02.txt,0_03.txt,0_04.txt,1_00.txt,1_01.txt,1_02.txt,1_03.txt,1_04.txt,1_05.txt,1_06.txt,1_07.txt,1_08.txt,1_09.txt,1_10.txt,1_11.txt,1_12.txt,1_13.txt,1_14.txt,2_00.txt,2_01.txt,2_02.txt,2_03.txt,2_04.txt,2_05.txt,2_06.txt,2_07.txt,2_08.txt,2_09.txt,2_10.txt,2_11.txt,2_12.txt,2_13.txt,2_14.txt,2_15.txt,2_16.txt,2_17.txt,2_18.txt,2_19.txt,2_20.txt,2_21.txt,2_22.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
0_00.txt AC 2 ms 2304 KB
0_01.txt AC 2 ms 2304 KB
0_02.txt AC 2 ms 2304 KB
0_03.txt AC 2 ms 2304 KB
0_04.txt AC 2 ms 2304 KB
1_00.txt AC 2 ms 2304 KB
1_01.txt AC 2 ms 2304 KB
1_02.txt AC 2 ms 2304 KB
1_03.txt AC 2 ms 2304 KB
1_04.txt AC 2 ms 2304 KB
1_05.txt AC 2 ms 2304 KB
1_06.txt AC 2 ms 2304 KB
1_07.txt AC 2 ms 2304 KB
1_08.txt AC 2 ms 2304 KB
1_09.txt AC 2 ms 2304 KB
1_10.txt AC 2 ms 2304 KB
1_11.txt AC 2 ms 2304 KB
1_12.txt AC 2 ms 2304 KB
1_13.txt AC 2 ms 2304 KB
1_14.txt AC 2 ms 2304 KB
2_00.txt AC 4 ms 4736 KB
2_01.txt AC 4 ms 4736 KB
2_02.txt AC 4 ms 4736 KB
2_03.txt AC 4 ms 4736 KB
2_04.txt AC 4 ms 4736 KB
2_05.txt AC 4 ms 4736 KB
2_06.txt AC 4 ms 4736 KB
2_07.txt AC 4 ms 4352 KB
2_08.txt AC 4 ms 4736 KB
2_09.txt AC 4 ms 4608 KB
2_10.txt AC 4 ms 4608 KB
2_11.txt AC 4 ms 4736 KB
2_12.txt AC 4 ms 4608 KB
2_13.txt AC 4 ms 4480 KB
2_14.txt AC 4 ms 4608 KB
2_15.txt AC 4 ms 4480 KB
2_16.txt AC 4 ms 4608 KB
2_17.txt AC 4 ms 4480 KB
2_18.txt AC 3 ms 4224 KB
2_19.txt AC 4 ms 4736 KB
2_20.txt AC 3 ms 4224 KB
2_21.txt AC 3 ms 4224 KB
2_22.txt AC 4 ms 4736 KB