Submission #1171408

#TimeUsernameProblemLanguageResultExecution timeMemory
1171408ibrahim001Red-blue table (IZhO19_stones)C++20
100 / 100
44 ms13128 KiB
#include "bits/stdc++.h" #include <chrono> #include <thread> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<pair<ld, int>, null_type,less<pair<ld, int>>, rb_tree_tag,tree_order_statistics_node_update> #define intt long long #define int intt #define pb push_back #define endl '\n' #define F first #define S second #define pii pair<int,int> #define pll pair<intt,intt> #define ld long double #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define all(x) x.begin(), x.end() using namespace std; // mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int sz = 2e5+5; const int sz1 = 2005; const int mod = 998244353; const int inf = 2e9+7; const intt infl = 1e18; const ld eps = 1e-9; int a[sz1][sz1], cnt[sz1]; int f(int n, int m){ int res = m; for ( int i = 1; i <= n; i++ ) for ( int j = 1; j <= m; j++ ) a[i][j] = 0, cnt[j] = 0; for ( int i = 1; i <= n; i++ ){ int cur = 0; vector<pii> v; for ( int j = 1; j <= m; j++ ){ if ( (cnt[j]+1)*2 < n ){ v.push_back({cnt[j], j}); } } if ( v.size()*2 <= m ) break; sort(all(v)); for ( int j = 0; ; j++ ){ a[i][v[j].second]=1; cnt[v[j].second]++; if ( (j+1)*2 > m ) break; } res ++; } return res; } int i,j; void solve(){ int n, m; cin >> n >> m; bool s = false; if ( n > m ) swap(n, m), s = true; cout << f(n, m) << endl; if ( s ) swap(n, m), s = true; for ( i = 1; i <= n; i++ ){ for ( j = 1; j <= m; j++ ){ if ( s ) cout << (a[j][i] ? '-' : '+'); else cout << (a[i][j] ? '+' : '-'); } cout << endl; } } signed main(){ fastio; int t = 1; cin >> t; for ( int cs = 1; cs <= t; cs++ ) { // cout << "Case " << cs << ": "; solve(); } // while ( cin >> n and n ){ // cin >> m; // 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...