Submission #898063

#TimeUsernameProblemLanguageResultExecution timeMemory
898063LitusianoRed-blue table (IZhO19_stones)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define f first
#define s second 
#define endl '\n'

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t; cin>>t;
	while(t--){
		int BOT = n/2;
		int BOT1 = m/2;
		int REM = n - BOT -1; 
		int REM1 = m-BOT1 - 1;
		int a = n;
		a+= n*REM1/(BOT+1);
		int b = m ;
		b+= m*REM/(BOT1+1);
		if(a >= b){
			cerr<<"HERE!"<<endl;
			int x = a-n;
			vector<vector<int>> v(n, vector<int>(m,1)); // all red
			vector<int> need(x,BOT+1);
			for(int i = 0; i<n; i++){
				int hv = REM1;
				
				for(int j = 0; j<REM1; j++){
					int mn = -INT_MAX; int idx = -1;
					for(int k = 0; k<need.size(); k++){
						if(need[k] > mn) mn = need[k], idx = k;
					}
					hv--;
					need[idx]--;
					// cerr<<i<<" "<<idx<<endl;
					v[i][idx] = 0;
				}

			}
			cout<<a<<endl;
			for(auto x : v){
				for(auto y : x){
					if(y) cout<<"+";
					else cout<<"-";
				}
				cout<<endl;
			}

		}	
		else{
			cerr<<"HERE1!"<<endl;
			int x = b-m;
			// He activat columnes, ara haig dactivar files.
			vector<vector<int>> v(n, vector<int>(m,0)); // all red
			vector<int> need(x,BOT1+1);
			for(int i = 0; i<m; i++){
				int hv = REM;
				for(int j = 0; j<REM; j++){
					int mn = -INT_MAX; int idx = -1;
					for(int k = 0; k<need.size(); k++){
						if(need[k] > mn) mn = need[k], idx = k;
					}
					hv--;
					need[idx]--;
					v[idx][i] = 1;
				}
			}
			cout<<b<<endl;
			for(auto x : v){
				for(auto y : x){
					if(y) cout<<"+";
					else cout<<"-";
				}
				cout<<endl;
			}

		}
	}

}
/*
1 3 7 9 10
10 + 24
9 + 11
7 + 4
1 + 3 

*/

Compilation message (stderr)

stones.cpp: In function 'int main()':
stones.cpp:14:13: error: 'n' was not declared in this scope
   14 |   int BOT = n/2;
      |             ^
stones.cpp:15:14: error: 'm' was not declared in this scope
   15 |   int BOT1 = m/2;
      |              ^
stones.cpp:32:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |      for(int k = 0; k<need.size(); k++){
      |                     ~^~~~~~~~~~~~
stones.cpp:62:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |      for(int k = 0; k<need.size(); k++){
      |                     ~^~~~~~~~~~~~