Submission #1132265

#TimeUsernameProblemLanguageResultExecution timeMemory
1132265AgageldiRed-blue table (IZhO19_stones)C++17
0 / 100
17 ms1864 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; 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(b[j] > (n + 1) / 2) { a[i][j] = '+'; r[i]++; b[j]--; if(j == m) j = 0; t = j + 1; } if(r[i] == m/2 + 1) break; } 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++; } cout << ans + m << '\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...