제출 #898032

#제출 시각아이디문제언어결과실행 시간메모리
898032LitusianoRed-blue table (IZhO19_stones)C++17
0 / 100
2045 ms38040 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 n,m; cin>>n>>m;
		int BOT = n/2;
		int BOT1 = m/2;
		int best = 0;
		int curans = 0;
		for(int i = 0; i<(1<<(n*m)); i++){
			vector<int> rows(n), columns(m);
			for(int k = 0; k<(n*m); k++){
				if(i & (1<<k)){
					// RED
					// cerr<<k/m<<" "<<n<<endl;
					rows[k/m]++;
				}
				else{
					columns[k%m]++;
				}
			}



			int ans = 0;
			for(int i : rows) ans+= (i>BOT1);
			for(int i : columns) ans+= i>(BOT);
			// cout<<ans<<endl;
			// for(int msk = 0; msk<n*m; msk++){
			// 	if((1<<msk) & i) cout<<'+';
			// 	else cout<<'-';
			// 	if(msk % m == (m-1)) cout<<endl;
			// }
			// cout<<"COLUMNS: ";
			// for(int i : columns) cout<<i<<" ";
			// cout<<endl<<"ROWS: ";
			for(int i : rows) cout<<i<<" "; cout<<endl;
			if(ans > curans) best = i, curans = ans;

		}
		cout<<curans<<endl;
		for(int i = 0; i<n*m; i++){
			if((1<<i) & best) cout<<'+';
			else cout<<'-';
			if(i % m == (m-1)) cout<<endl;
		}
	}

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

*/ 

컴파일 시 표준 에러 (stderr) 메시지

stones.cpp: In function 'int main()':
stones.cpp:46:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   46 |    for(int i : rows) cout<<i<<" "; cout<<endl;
      |    ^~~
stones.cpp:46:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   46 |    for(int i : rows) cout<<i<<" "; cout<<endl;
      |                                    ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...