Submission #57269

# Submission time Handle Problem Language Result Execution time Memory
57269 2018-07-14T12:36:57 Z dennisstar 여왕벌 (KOI15_queen) C++11
0 / 100
5000 ms 11176 KB
#include <bits/stdc++.h>
int M, N;
char c[710][710][3][3][3];
int sum[710][710];
int main()
{
	int i, j, k;
	scanf("%d %d", &M, &N);
	for (i=1; i<M; i++) for (j=1; j<M; j++) for (k=0; k<27; k++) scanf(" %c", &c[i][j][k/9][(k%9)/3][k%3]);
	int x, y, z;
	for (i=1; i<M; i++) for (j=1; j<M; j++) for (x=0; x<3; x++) for (y=0; y<3; y++) for (z=0; z<3; z++) {
		if (c[i][j][x][y][z]=='L') c[i][j][x][y][z]=x;
		else if (c[i][j][x][y][z]=='D') c[i][j][x][y][z]=y;
		else c[i][j][x][y][z]=z;
	}
	int l, r, lp, rp;
	for (i=0; i<N; i++) {
		scanf("%d %d %d", &x, &y, &z);
		l=(x<M?0:x-M+1);
		r=(z>=M?0:M-z);
		sum[0][l]++, sum[0][r]++;
		for (j=1; x+y+j<M; j++) {
			lp=l, rp=r;
			if (l==r) {
				if (r) for (; r<M; r++) if (c[j][r][0][r-1<lp?0:r-1<rp?1:2][2]==2) break;
				sum[j][r]+=2;
				l=r;
			}
			else {
				if (l&&l<M) for (; l<M; l++) if (c[j][l][0][(l-1<rp?l-1<lp?0:1:2)][(l<rp?l<lp?0:1:2)]==1) break;
				r=std::max(l,r);
				if (r&&r<M) {
					if (c[j][r][(l==r?0:1)][(r-1<rp?r-1<lp?0:1:2)][2]!=2) r++;
					for (; r<M; r++) if (c[j][r][1][2][2]==2) break;
				}
				sum[j][l]++, sum[j][r]++;
			}
		}
		if (x+y+j==M) r++;
		for (; x+j<M; j++) {
			lp=l, rp=r;
			if (l==r) {
				if (r) for (; r<M; r++) if (c[j][r][0][r-1<lp?0:r-1<rp?1:2][2]==2) break;
				sum[j][r]+=2;
				l=r;
			}
			else {
				if (l&&l<M) for (; l<M; l++) if (c[j][l][0][(l-1<rp?l-1<lp?0:1:2)][(l<rp?l<lp?0:1:2)]==1) break;
				r=std::max(l,r);
				if (r&&r<M) {
					if (c[j][r][(l==r?0:1)][(r-1<rp?r-1<lp?0:1:2)][2]!=2) r++;
					for (; r<M; r++) if (c[j][r][1][2][2]==2) break;
				}
				sum[j][l]++, sum[j][r]++;
			}
		}
		if (x+j==M) l++;
		for (; j<M; j++) {
			lp=l, rp=r;
			if (l==r) {
				if (r) for (; r<M; r++) if (c[j][r][0][r-1<lp?0:r-1<rp?1:2][2]==2) break;
				sum[j][r]+=2;
				l=r;
			}
			else {
				if (l&&l<M) for (; l<M; l++) if (c[j][l][0][(l-1<rp?l-1<lp?0:1:2)][(l<rp?l<lp?0:1:2)]==1) break;
				r=std::max(l,r);
				if (r&&r<M) {
					if (c[j][r][(l==r?0:1)][(r-1<rp?r-1<lp?0:1:2)][2]!=2) r++;
					for (; r<M; r++) if (c[j][r][1][2][2]==2) break;
				}
				sum[j][l]++, sum[j][r]++;
			}
		}
	}
	for (i=0; i<M; i++) {
		for (j=1; j<M; j++) {
			sum[i][j]+=sum[i][j-1];
		}
	}
	for (i=0; i<M; i++) {
		for (j=0; j<M; j++) {
			printf("%d ", sum[i][j]+1);
		}
		puts("");
	}
	return 0;
}

Compilation message

queen.cpp: In function 'int main()':
queen.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &M, &N);
  ~~~~~^~~~~~~~~~~~~~~~~
queen.cpp:9:68: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i=1; i<M; i++) for (j=1; j<M; j++) for (k=0; k<27; k++) scanf(" %c", &c[i][j][k/9][(k%9)/3][k%3]);
                                                               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
queen.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &x, &y, &z);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 412 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5095 ms 11176 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 11176 KB Output isn't correct
2 Halted 0 ms 0 KB -