Submission #158905

#TimeUsernameProblemLanguageResultExecution timeMemory
158905elizavetaaRed-blue table (IZhO19_stones)C++14
100 / 100
95 ms2424 KiB
//#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4") #include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //#include <ext/pb_ds/detail/standard_policies.hpp> #define pb push_back #define F first #define S second #define ll long long #define lld long double #define pii pair < int, int > using namespace std; //template <typename T> //using ordered_set = tree <T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; const int N = 3e5 + 229; const int M = 1e9 + 7; const ll M2 = 1e9 + 9; const int mod = 998244353; const int Sx[8] = {1, 1, -1, -1, -2, 2, 2, -2}; const int Sy[8] = {-2, 2, 2, -2, 1, 1, -1, -1}; const lld eps = 1e-7; const double pi = acos(-1.0); //mt19937 gen(chrono::system_clock::now().time_since_epoch().count()); int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // srand(time(0)); #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); #endif int t; cin >> t; while(t--) { int n, m; cin >> n >> m; if(n <= m) { int ans = m; char a[n][m]; pair <int, int> k[m]; for(int i = 0; i < n; ++i) { for(int j = 0; j < m; ++j) { a[i][j] = '-'; k[j].F = 0;k[j].S = j; } } int pos = m / 2 + 1; int cnt = n / 2; if(n % 2 == 0)cnt--; for(int z = 0; z < n; ++z) { if(k[pos - 1].F >= cnt)break; ans++; for(int i = 0; i < pos; ++i) { a[z][k[i].S] = '+'; k[i].F++; } sort(k, k + m); } cout << ans << endl; for(int i = 0; i < n; ++i) { for(int j = 0; j < m; ++j) cout << a[i][j]; cout << endl; } } else { int ans = n; char a[n][m]; pair <int, int> k[n]; for(int i = 0; i < n; ++i) { for(int j = 0; j < m; ++j) { a[i][j] = '+'; } k[i].F = 0;k[i].S = i; } int pos = n / 2 + 1; int cnt = m / 2; if(m % 2 == 0)cnt--; for(int z = 0; z < m; ++z) { if(k[pos - 1].F >=cnt)break; ans++; for(int i = 0; i < pos; ++i) { // cerr <<k[i].S << endl; a[k[i].S][z] = '-'; k[i].F++; } // cerr << endl; sort(k, k + n); //for(int i = 0; i < n; ++i) // cout << k[i].F << ' ' << k[i].S << endl; // cout << endl; } cout << ans << endl; for(int i = 0; i < n; ++i) { for(int j = 0; j < m; ++j) cout << a[i][j]; cout << endl; } } }}
#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...