Submission #384819

# Submission time Handle Problem Language Result Execution time Memory
384819 2021-04-02T11:05:22 Z Kalashnikov Red-blue table (IZhO19_stones) C++17
0 / 100
107 ms 1900 KB
#include <bits/stdc++.h>
 
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second
 
using namespace std;
using ll = long long;
 
const int N = 1000+5 , inf = 2e9 + 7;
const ll INF = 1e18 ,   mod = 1e9+7 , P = 6547;

int a[N][N];

void solve() {
	int n , m;
	cin >> n >> m;
	for(int i = 1; i <= n; i ++) {
		for(int j = 1; j <= m; j ++) {
			a[i][j] = -1;
		}
	}
	set<pair<int,int>> st;
	for(int i = 1; i <= m; i ++) {
		if((n+1)/2-1)
			st.insert({0 , i});
	}
	int x = (m+1)/2;
	int ans = m;
	for(int i = 1; i <= n; i ++) {
		int p = x;
		int ok = 1;
		vector<int> v;
		while(p --) {
			if(st.empty()) {
				ok = 0;
				break;
			}
			pair<int,int> cur = *st.begin();
			v.push_back(cur.S);
			st.erase(cur);
			cur.F ++;
			if(cur.F < (n+1)/2-1) {
				st.insert(cur);
			}
		}
		if(ok) {
			for(auto to: v) {
				a[i][to] = 1;
			}
			ans ++;
		}
	}
	cout << ans << '\n';
	for(int i = 1; i <= n; i ++) {
		for(int j = 1; j <= m; j ++)
			if(a[i][j] == 1) cout << '+';
			else cout << '-';
			
		cout << '\n';
	}
}
/*
*/
main() {
    ios;
    int tt = 1;
    cin >> tt;
    while(tt --) {
        solve();
    }
    return 0;
}

Compilation message

stones.cpp:67:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   67 | main() {
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Wrong answer in test 2 1: 1 < 2
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 768 KB Wrong answer in test 2 1: 1 < 2
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Wrong answer in test 2 1: 1 < 2
# Verdict Execution time Memory Grader output
1 Incorrect 107 ms 1772 KB Wrong answer in test 97 21: 112 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 97 ms 1900 KB in the table A+B is not equal to 46
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Wrong answer in test 2 1: 1 < 2