Submission #1158021

#TimeUsernameProblemLanguageResultExecution timeMemory
1158021dostsRed-blue table (IZhO19_stones)C++20
0 / 100
0 ms320 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2") using namespace std; #define int long long #define pii pair<int,int> #define ff first #define ss second #define sp << " " << #define all(cont) cont.begin(),cont.end() #define vi vector<int> const int inf = 2e18,N = 5e5+1,MOD = 1e9+7; void solve() { exit(1); int ans = 0; int n,m; cin >> n >> m; int R = 0; for (int r = 0;r <= n;r++) { //r tanesinde m/2+1 tane + olcak int need = max(0ll,n/2+1-(n-r)); int have = r*(m-(m/2+1)); int colstodo = need?min(m,have/need):m; if (r+colstodo > ans) { ans = (r+colstodo); R = r; } } cout << ans << endl; int r = R; if (!r) { for (int i = 0;i<n;i++) { for (int j = 0;j<m;j++) cout << '-'; cout << '\n'; } return; } vector<vector<char>> brd(n,vector<char>(m,'-')); for (int i = 0;i<r;i++) { for (int j = 0;j<m;j++) brd[i][j] = '+'; } int need = max(0ll,n/2+1-(n-r)); vi got(r,(m-(m/2+1))); int ptr = 0; int col = -1; while (col < m-1) { ++col; int fl = 1; for (int j = ptr,ctr = 0;ctr < need;ctr++,j = (j+1)%r) { if (!got[j]) fl = 0; } if (!fl) break; for (int j = ptr,ctr = 0;ctr < need;ctr++,j = (j+1)%r) { brd[j][col] = '-'; got[j]--; assert(brd[j].size() > col); } ptr = (ptr+need)%r; } for (int i = 0;i<n;i++) { for (int j = 0;j<m;j++) cout << brd[i][j]; cout << '\n'; } } int32_t main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #ifdef Dodi freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif int t = 1; cin >> t; while (t --> 0) solve(); }
#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...