Submission #342067

# Submission time Handle Problem Language Result Execution time Memory
342067 2021-01-01T09:40:36 Z NurstanDuisengaliev Red-blue table (IZhO19_stones) C++14
11 / 100
76 ms 4972 KB
// Nurstan Duisengaliev
// не, не надо меня узнавать 
/*#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")*/                   
      
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define pll pair <ll, ll>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
 
using namespace std;
//using namespace __gnu_pbds;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;                         
 
const int N = 1005;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 1;
int n, m, a[N][N]; 
void calc (int x, int y) {
	for (int i = 1; i <= x; i ++) {
		for (int j = 1; j <= y; j ++) {
			a[i][j] = 0;
		}
	}	
	for (int i = n; i > n - x; i --) {
		for (int j = m; j > m - y; j --) {
			a[i][j] = 0;
		}
	}
}
void solve () {
	cin >> n >> m;
	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= m; j ++) a[i][j] = 1;
	}
	if (min (n, m) == 1) {
	    if (n == 1) {         
			cout << m << endl;
			calc (n, m);      
		}                     
		else {                
			cout << n << endl;
	    }                     
	}
	else if (n % 2 == 1 && m % 2 == 1) {
		cout << n - 1 + m - 1 << endl;
		calc (n / 2 + 1, m / 2);
	}
	else if (n % 2 == 0 && m % 2 == 0) {
		if (m == 2) {
			cout << n << endl;
		}
		else if (n == 2) {
			cout << m << endl;
			calc (n, m);
		}
		else {
			cout << n - 2 + m - 2 << endl;
			calc (n / 2 + 1, m / 2 - 1);
		}
	}
	else if (n % 2 == 0 && m % 2 == 1) {
		if (n == 2) {
			cout << m << endl;
			calc (n, m);
		}
		else {
			cout << n - 2 + m - 1 << endl;
			calc (n / 2 + 1, m / 2);
		}
	}
	else if (n % 2 == 1 && m % 2 == 0) {
		if (m == 2) {
			cout << n << endl;
		}	
		else {
			cout << n - 1 + m - 2 << endl;
			calc (n / 2 + 1, m / 2 - 1);
		}
	}
	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= m; j ++) {
			cout << (a[i][j] == 1 ? '+' : '-');
		}
		cout << endl;
	}
}   	    		
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT;
    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	                                    
}                                                   

Compilation message

stones.cpp:107:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  107 | main () {
      |       ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Wrong answer in test 4 4: 4 < 5
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 492 KB Wrong answer in test 4 3: 4 < 5
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Wrong answer in test 4 4: 4 < 5
# Verdict Execution time Memory Grader output
1 Correct 76 ms 1772 KB Output is correct
2 Correct 34 ms 4204 KB Output is correct
3 Correct 34 ms 4972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 1900 KB Wrong answer in test 4 4: 4 < 5
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Wrong answer in test 4 4: 4 < 5