Submission #1132266

#TimeUsernameProblemLanguageResultExecution timeMemory
1132266AgageldiRed-blue table (IZhO19_stones)C++17
15 / 100
16 ms4676 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define N 400005 #define ff first #define ss second #define pb push_back #define sz(s) (int)s.size() #define rep(c, a, b) for(c = a; c <= b; c++) ll n, t, b[N], m, T, r[N]; char a[5000][5000]; int main () { ios::sync_with_stdio(0);cin.tie(0); cin >> T; while(T--) { cin >> n >> m; if(n > m) swap(n,m); for(int i = 1; i <= m; i++) { b[i] = n; } for(int i = 1; i <= n; i++) { r[i] = 0; for(int j = 1; j <= m; j++) { a[i][j] = '-'; } } int cnt = 1, ans = 0; for(int i = 1; i <= n; i++) { t = cnt; for(int j = cnt; j <= m; j++) { if(r[i] == m/2 + 1 || b[j] == (n/2) + 1) break; if(b[j] > (n + 1) / 2) { a[i][j] = '+'; r[i]++; b[j]--; if(j == m) j = 0; t = j + 1; } } cnt = t; } for(int i= 1;i<=n;i++) { t = 0; for(int j = 1; j <= m; j++) { if(a[i][j] == '+') t++; else t--; } if(t > 0) ans++; } for(int i =1;i<=m;i++) { t = 0; for(int j =1;j<=n;j++) { if(a[j][i] == '-') t++; else t--; } if(t > 0) ans++; } cout << ans << '\n'; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++) { cout << a[i][j]; } cout << '\n'; } } }
#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...