Submission #202111

# Submission time Handle Problem Language Result Execution time Memory
202111 2020-02-13T23:25:40 Z ZwariowanyMarcin Red-blue table (IZhO19_stones) C++14
11 / 100
45 ms 4984 KB
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl

using namespace std;

const int nax = 1011;

int T, n, m;

int t[nax][nax];

int main() {
	scanf ("%d", &T);
	while (T--) {
		scanf ("%d%d", &n, &m);
		if (n == 1) {
			printf ("%d\n", m);
			for (int i = 1; i <= m; ++i)
				printf ("-");
			printf ("\n");
			continue;
		}
		if (m == 1) {
			printf ("%d\n", n);
			for (int i = 1; i <= n; ++i)
				printf ("+\n");
			printf ("\n");
			continue;
		}
		
		int ans = n + m - 2;
		
		int N = n;
		int M = m;
		
		if (N % 2 == 0) N--, ans--;
		if (M % 2 == 0) M--, ans--;
		
		for (int row = 1; row < N; ++row)
			for (int col = 1; col <= M; ++col) {
				if (col == M / 2 + 1) 
					t[row][col] = 1;
				else if (col < M / 2 + 1)
					t[row][col] = (row & 1);
				else
					t[row][col] = !(row & 1);
			}
			
		for (int col = 1; col <= M; ++col)
			t[N][col] = 0;
		
		if (n != N) {
			for (int col = 1; col <= m; ++col)
				t[n][col] = 0;
		}
		
		if (m != M) {
			for (int row = 1; row <= n; ++row)
				t[row][m] = 1;
		}
		
		printf ("%d\n", ans);
		
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= m; ++j) {
				printf ((t[i][j] == 1 ? "+" : "-"));
			}
			printf ("\n");
		}
	}			
	
	return 0;
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d", &T);
  ~~~~~~^~~~~~~~~~
stones.cpp:21:9: 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 5 ms 376 KB Output is correct
2 Incorrect 5 ms 248 KB in the table A+B is not equal to 2
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 504 KB Wrong answer in test 20 2: 18 < 20
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 248 KB in the table A+B is not equal to 2
# Verdict Execution time Memory Grader output
1 Correct 45 ms 1784 KB Output is correct
2 Correct 38 ms 4216 KB Output is correct
3 Correct 34 ms 4984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 1912 KB in the table A+B is not equal to 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 248 KB in the table A+B is not equal to 2