# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
382102 | 2021-03-26T11:51:01 Z | vanic | Red-blue table (IZhO19_stones) | C++14 | 84 ms | 1516 KB |
#include <iostream> #include <cmath> #include <algorithm> #include <cassert> #include <set> using namespace std; const int maxn=1005; char c[maxn][maxn]; set < pair < int, int > > s; void solve(){ int n, m; cin >> n >> m; int c1=(n+2)/2; int c2=(m+2)/2; int uk=n*m; int sol=0; int 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; najb=b; } } cout << sol << '\n'; // cout << naja << ' ' << najb << endl; for(int i=0; i<m; 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=0; i<najb; i++){ for(int j=0; j<m; j++){ cout << c[i][j]; } cout << '\n'; } for(int i=0; i<n-najb; i++){ for(int j=0; j<m; j++){ cout << '-'; } 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 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 | 2 ms | 364 KB | in the table A+B is not equal to 5 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 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 | 1516 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 | 84 ms | 1516 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 | 1 ms | 364 KB | in the table A+B is not equal to 4 |
2 | Halted | 0 ms | 0 KB | - |