# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1025294 | 2024-07-16T19:21:11 Z | hasan2006 | Red-blue table (IZhO19_stones) | C++17 | 28 ms | 4944 KB |
#include <bits/stdc++.h> using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define se second #define fi first #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N = 1e3 + 9 , mod = 1e9 + 7; int a[N][N] , b[N] , dp[N] , c[N] ; void solve() { ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ; cin>>n>>m; ll N = n, M = m; if(n < m) swap(n , m); for(i = 1; i <= n; i++) for(j = 1; j <= m; j++) a[i][j] = 0 ,b[i] = m , c[j] = 0; f = n / 2 + 1; x = m / 2 - (m % 2 == 0) , y = 1; for(i = 1; i <= n; i++){ for(j = y; j < y + x; j++) a[i][j] = 1 , c[j]++ , b[i]--; if(c[y] >= f) y = y + x; } k = 1; x = min(m - y + 1 , x); while((f - c[y] < x) && k + (f - c[y] - 1) <= n && (y + x - 1) <= m){ for(i = k; i < i + f - c[y]; i++) for(j = y ; j < y + x; j++) a[i][j] = 1 , b[i]-- , c[j]++; i = i + f - c[y]; y = y + x; } for(i = 1; i <= n; i++) s += (b[i] > m / 2); for(i = 1; i <= m; i++) s += (c[i] > n / 2); cout<<s<<"\n"; for(i = 1; i <= N; i++){ for(j = 1; j <= M; j++){ x = (N < M ? a[j][i] : 1 - a[i][j]); cout<<(x == 1 ? "+" : "-"); } cout<<"\n"; } } int main(){ TL; int t = 1; cin>>t; while(t--) { solve(); } } // Author : حسن
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 460 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2652 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 2652 KB | Output is correct |
4 | Incorrect | 1 ms | 2652 KB | Wrong answer in test 38 5: 40 < 41 |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 3676 KB | Output is correct |
2 | Correct | 27 ms | 4692 KB | Output is correct |
3 | Correct | 27 ms | 4944 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 28 ms | 3628 KB | Wrong answer in test 6 6: 8 < 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 2652 KB | Output is correct |
4 | Incorrect | 1 ms | 2652 KB | Wrong answer in test 38 5: 40 < 41 |
5 | Halted | 0 ms | 0 KB | - |