Submission #919560

#TimeUsernameProblemLanguageResultExecution timeMemory
919560manizareRed-blue table (IZhO19_stones)C++14
17 / 100
38 ms3408 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3,unroll-loops") #pragma GCC target("avx2") #define pb push_back #define F first #define S second #define all(a) a.begin(),a.end() #define pii pair <int,int> #define PII pair<pii , pii> #define int long long #define sz(v) (int)v.size() #define rep(i , a , b) for(int i=a;i <= (b);i++) #define per(i , a , b) for(int i=a;i >= (b);i--) #define deb(x) cout <<#x << " : " << x << "\n" ; using namespace std ; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int maxn = 1e6+ 10 , maxm = 1e6+10 , lg = 18 , inf= 1e18 , mod = 998244353 ; int t[maxn] ;char A[maxn] ; int f(int a ,int n){ return max(0ll , (n+2)/2 - (n-a)); } signed main(){ ios_base::sync_with_stdio(false);cin.tie(0); int T ; cin >> T ; while(T--){ int n , m ; cin >> n >> m ; int mx = -1 , a , b ; rep(i , 0 , n){ int l =0 , r = m+1 ; while(r-l>1){ int mid = (l+r)/2 ; if(f(mid , m)*i+f(i , n)*mid > i*mid){ r = mid ; }else{ l = mid ; } } if(mx < l+i){ a = i ; b = l ; mx = l+i ; } } cout << mx << "\n"; rep(i , 1, b){ t[i] = f(i , n) ; } rep(i , 1 ,a){ vector <pii> vec; rep(i , 1 , b){ vec.pb({t[i] ,i}) ; A[i] = '+' ; } sort(all(vec)) ; int x = b-f(b , m) ; while(x--){ A[vec.back().S] = '-' ; vec.pop_back() ; } rep(i , 1 ,b){ cout << A[i] ; } rep(i , b+1 ,m ){ cout << "+"; } cout << "\n"; } rep(i , a+1 , n){ rep(j ,1 , m){ cout << "-"; } cout << "\n"; } } } /* */

Compilation message (stderr)

stones.cpp: In function 'int main()':
stones.cpp:59:30: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
   59 |             int x = b-f(b , m) ;
      |                              ^
stones.cpp:12:38: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
   12 | #define rep(i , a , b) for(int i=a;i <= (b);i++)
      |                                      ^~
stones.cpp:31:23: note: 'a' was declared here
   31 |         int mx = -1 , a , b ;
      |                       ^
#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...