Submission #167423

# Submission time Handle Problem Language Result Execution time Memory
167423 2019-12-08T14:10:26 Z tincamatei Red-blue table (IZhO19_stones) C++14
15 / 100
28 ms 1912 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1000;
char matr[MAX_N][MAX_N];

int main() {
	int T, N, M;
	scanf("%d", &T);
	while(T--) {
		int best = 0, bestFR = -1;
		scanf("%d%d", &N, &M);
		
		for(int fixedRows = 0; fixedRows <= N; ++fixedRows) {
			int fixedColumns = 0;
			int reqCols = (M + 2) / 2, pluses = reqCols * fixedRows;
			int fullLayers = pluses / M, overflownLayers = pluses % M, normalLayers = M - overflownLayers;
			
			if(N - fullLayers >= (N + 2) / 2)
				fixedColumns += normalLayers;
			if(N - (fullLayers + 1) >= (N + 2) / 2)
				fixedColumns += overflownLayers;
		
			if(fixedColumns + fixedRows > best) {
				best = fixedColumns + fixedRows;
				bestFR = fixedRows;
			}
		}
	
		for(int r = 0; r < N; ++r)
			for(int c = 0; c < M; ++c)
				matr[r][c] = '-';
	
		int lastP = 0;
		printf("%d\n", best);
		for(int i = 0; i < bestFR; ++i) {
			for(int j = 0; j < (M + 2) / 2; ++j) {
				matr[i][lastP] = '+';
				lastP = (lastP + 1) % M;
			}
		}

		for(int r = 0; r < N; ++r) {
			for(int c = 0; c < M; ++c)
				fputc(matr[r][c], stdout);
			printf("\n");
		}
	}
	return 0;
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &T);
  ~~~~~^~~~~~~~~~
stones.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &N, &M);
   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong answer in test 4 3: 4 < 5
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 376 KB Wrong answer in test 4 3: 4 < 5
# Verdict Execution time Memory Grader output
1 Correct 10 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong answer in test 4 3: 4 < 5
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 1400 KB Wrong answer in test 97 21: 112 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1528 KB Output is correct
2 Correct 23 ms 1912 KB Output is correct
3 Correct 21 ms 1696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong answer in test 4 3: 4 < 5