# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
382107 | 2021-03-26T11:59:16 Z | vanic | Red-blue table (IZhO19_stones) | C++14 | 84 ms | 2156 KB |
#include <iostream> #include <cmath> #include <algorithm> #include <cassert> #include <set> using namespace std; const int maxn=1005; int n, m; char c[maxn][maxn]; set < pair < int, int > > s; int prebroji(){ int sum=0; int br; for(int i=0; i<n; i++){ br=0; for(int j=0; j<m; j++){ if(c[i][j]=='+'){ br++; } } if(br>m/2){ sum++; } } for(int j=0; j<m; j++){ br=0; for(int i=0; i<n; i++){ if(c[i][j]=='-'){ br++; } } if(br>n/2){ sum++; } } return sum; } void solve(){ cin >> n >> m; int c1=(n+2)/2; int c2=(m+2)/2; int uk=n*m; int sol=0; int naja, najb; int a, b; for(int i=0; i<=m; i++){ a=i; b=min(n, (uk-c1*a)/c2); if(a+b>sol){ sol=a+b; naja=a; najb=b; } } // cout << sol << '\n'; // cout << naja << ' ' << najb << endl; for(int i=0; i<naja; i++){ s.insert({0, i}); } for(int i=0; i<n; i++){ for(int j=0; j<m; j++){ c[i][j]='+'; } } int cor; for(int i=0; i<najb; i++){ for(int j=0; j<(m-1)/2; j++){ cor=s.begin()->second; s.insert({s.begin()->first+1, s.begin()->second}); s.erase(s.begin()); c[i][cor]='-'; } } for(int i=najb; i<n; i++){ for(int j=0; j<m; j++){ c[i][j]='-'; } } cout << prebroji() << '\n'; for(int i=0; i<n; i++){ for(int j=0; j<m; j++){ cout << c[i][j]; } cout << '\n'; } s.clear(); } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while(t--){ solve(); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Wrong answer in test 3 4: 4 < 5 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 364 KB | Wrong answer in test 3 6: 6 < 7 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Wrong answer in test 3 4: 4 < 5 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 84 ms | 1504 KB | Output is correct |
2 | Correct | 82 ms | 2028 KB | Output is correct |
3 | Correct | 75 ms | 2156 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 83 ms | 1516 KB | Output is correct |
2 | Correct | 71 ms | 1900 KB | Output is correct |
3 | Correct | 67 ms | 1676 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Wrong answer in test 3 4: 4 < 5 |