Submission #170862

# Submission time Handle Problem Language Result Execution time Memory
170862 2019-12-26T15:39:50 Z Trickster Red-blue table (IZhO19_stones) C++14
0 / 100
90 ms 1528 KB
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define N 1010
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mod 1000000007
#define pii pair <int, int>

using namespace std;

int t;
int n, m;
char v[N][N];

int main()
{
	cin >> t;
	
	while(t--) {
		cin >> n >> m;
		
		int ans = max(n, m);
		for(int i = 1; i <= n; i++)
			for(int h = 1; h <= m; h++)
				v[i][h] = (n > m ? '+' : '-');
		
		if(n < m) {
			priority_queue <pii, vector <pii>, greater<pii>> Q;
			
			for(int i = 1; i <= m; i++) Q.push({0, i});
			
			int li = m/2 + 1;
			int sz = n/2 - (n%2 == 0 ? 1 : 0);
			for(int i = 1; i <= n; i++) {
				vector <pii> A;
				
				for(int h = 1; h <= li; h++) {
					pii x = Q.top();
					Q.pop();
					
					if(x.ff == sz) break;
					
					A.pb(x);
					
					if(Q.empty()) break;
				}
				
				if(A.size() < li) break;
				
				ans++;
				for(auto h: A) v[i][h.ss] = '+', Q.push({h.ff+1, h.ss});
			}
		}
		else {
			priority_queue <pii, vector <pii>, greater<pii>> Q;
			
			for(int i = 1; i <= n; i++) Q.push({0, i});
			
			int li = n/2 + 1;
			int sz = m/2 - (m%2 == 0 ? 1 : 0);
			for(int i = 1; i <= m; i++) {
				vector <pii> A;
				
				for(int h = 1; h <= li; h++) {
					pii x = Q.top();
					Q.pop();
					
					if(x.ff == sz) break;
					
					A.pb(x);
					
					if(Q.empty()) break;
				}
				
				if(A.size() < li) break;
				
				ans++;
				for(auto h: A) v[h.ss][i] = '+', Q.push({h.ff+1, h.ss});
			}
		}
		
		cout << ans << "\n";
		for(int i = 1; i <= n; i++) {
			for(int h = 1; h <= m; h++)
				cout << v[i][h];
			
			cout << "\n";
		}
	}
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:57:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(A.size() < li) break;
        ~~~~~~~~~^~~~
stones.cpp:84:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(A.size() < li) break;
        ~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB in the table A+B is not equal to 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 376 KB in the table A+B is not equal to 5
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB in the table A+B is not equal to 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 83 ms 1528 KB in the table A+B is not equal to 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 1528 KB in the table A+B is not equal to 44
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB in the table A+B is not equal to 4
2 Halted 0 ms 0 KB -