Submission #216645

#TimeUsernameProblemLanguageResultExecution timeMemory
216645eggag32Red-blue table (IZhO19_stones)C++17
27 / 100
69 ms1400 KiB
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef pair<int, int> pi; #define debug(x) cerr << #x << ": " << x << endl; #define debug2(x, y) debug(x) debug(y); #define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++) #define rep(i, a) for(int i = 0; i < (int)(a); i++) #define all(v) v.begin(), v.end() #define mp make_pair #define pb push_back #define lb lower_bound #define ub upper_bound #define fi first #define se second #define sq(x) ((x) * (x)) template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); } void solve(){ int n, m; cin >> n >> m; int ans = n; //do the rows vi cn(n, 0); //capacity of each row rep(i, n) cn[i] = (m - 1) / 2; char res[n + 1][m + 1]; rep(i, n) rep(j, m) res[i][j] = '+'; rep(j, m){ int need = (n + 2) / 2; //how many need to be changed rep(i, n){ if(!need) break; else if(cn[i]) cn[i]--, need--, res[i][j] = '-'; } if(!need) ans++; else break; } int ans1 = m; vi cn1(m, 0); rep(i, m) cn1[i] = (n - 1) / 2; char res1[n + 1][m + 1]; rep(i, n) rep(j, m) res1[i][j] = '-'; rep(i, n){ int need = (m + 2) / 2; //how many need to be changed rep(j, m){ if(!need) break; else if(cn1[j]) cn1[j]--, need--, res1[i][j] = '+'; } if(!need) ans1++; else break; } if(ans > ans1){ cout << ans << endl; rep(i, n){ rep(j, m) cout << res[i][j]; cout << endl; } } else{ cout << ans1 << endl; rep(i, n){ rep(j, m) cout << res1[i][j]; cout << endl; } } } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); //freopen("input.in", "r", stdin); //freopen("output.out", "w", stdout); int t; cin >> t; while(t--) solve(); return 0; } /* Things to look out for: - Integer overflows - Array bounds - Special cases Be careful! */
#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...