Submission #652571

# Submission time Handle Problem Language Result Execution time Memory
652571 2022-10-23T08:22:40 Z l3nl3 Red-blue table (IZhO19_stones) C++17
0 / 100
21 ms 212 KB
/* #pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops") */

#include <bits/stdc++.h>

#define int long long

using namespace std;

int tc; 

signed main () {
 	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> tc;
	while (tc--) {
		int n, m;
		cin >> n >> m;
		if (n <= 4 && m <= 4) {
			char a[n+1][m+1];
			int k = n*m;
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= m; j++) {
					a[i][j] = '.';				
				}
			}
			int mx = -1, mxi = -1;
			for (int mask = 0; mask <= (1 << k); mask++) {
				for (int i = 0; i < k; i++) {
					int x = i/n, y = i%m;
					x++;
					y++;
					if ((1 << i) & mask) {
						a[x][y] = '+';
					} else {
						a[x][y] = '-';
					}
				}
				int cnt = 0;
				for (int i = 1; i <= n; i++) {
					int r = 0, b = 0;
					for (int j = 1; j <= m; j++) {
						if (a[i][j] == '+') {
							r++;
						} else {
							b++;
						}
					}
					if (r > b) cnt++;
				}
				for (int j = 1; j <= m; j++) {
					int r = 0, b = 0;
					for (int i = 1; i <= n; i++) {
						if (a[i][j] == '+') {
							r++;
						} else {
							b++;
						}
					}
					if (r > b) cnt++;					
				}
				if (cnt > mx) {
					mx = cnt;
					mxi = mask;
				}
				for (int i = 1; i <= n; i++) {
					for (int j = 1; j <= m; j++) {
						a[i][j] = '.';				
					}
				}
			}
			for (int i = 0; i < k; i++) {
				int x = i%n, y = i%m;
				x++;
				y++;
				//cerr << x << ' ' << y << '\n';
				if ((1 << i) & mxi) {
					a[x][y] = '+';
				} else {
					a[x][y] = '-';
				}
			}
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= m; j++) {
					cout << a[i][j];
				}
				cout << '\n';
			}           				
		}
	}		
}                          	
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Expected integer, but "+--" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 212 KB Expected integer, but "-" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Expected integer, but "+--" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Expected integer, but "+.." found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 212 KB Expected integer, but "+" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Expected integer, but "+--" found
2 Halted 0 ms 0 KB -