Submission #159648

#TimeUsernameProblemLanguageResultExecution timeMemory
159648Dima_BorchukRed-blue table (IZhO19_stones)C++17
0 / 100
87 ms1360 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int q , n , m; cin >> q; while(q--){ cin >> n >> m; int ans = m , k; vector<pair<int , int>> v(m + 1); int line[n + 1] = {0}; char a[n + 5][m + 5]; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ a[i][j] = '-'; } } for(int i = 1; i <= m; i++){ v[i].second = i; } int l = 1; while(l <= n){ for(int r = 1; r <= m; r++){ if(v[r].first + 1 < (n + 1 ) / 2 && line[l] <= m / 2){ a[l][v[r].second] = '+'; v[r].first++; line[l]++; } } l++; } for(int i = 1; i <= n; i++){ k = 0; for(int j = 1; j <= n; j++){ if(a[i][j] == '+') k++; } if(k > m / 2) ans++; } cout << ans << endl; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ cout << a[i][j]; } cout << endl; } } return 0; }
#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...