제출 #419524

#제출 시각아이디문제언어결과실행 시간메모리
419524KalasLavasXylophone (JOI18_xylophone)C++14
0 / 100
2 ms200 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; mt19937 rng(chrono::system_clock::now().time_since_epoch().count()); //#undef LOCALKL #define IO \ ios_base::sync_with_stdio(0);(cin).tie(0);(cout).tie(0) #define y1 y1_ #define prev prev_ #define all(a) (a).begin(),(a).end() #define pb push_back #define eb emplace_back #define F first #define S second #ifdef LOCALKL // #define cerr cerr<<"\33[1;32m" // #define cout cout<<"\33[0m" #else #ifndef OO #define endl '\n' #define cerr if(1){}else cerr #endif #endif #define OK cout<<"OK\n"<<endl; #define setpre(k) fixed<<setprecision(k) #define mmset(k,y) memset(k,y,sizeof(k)) #define sz(x) ((int)(x).size()) using pii = pair<int,int>; using pll = pair<long long,long long>; using ull = unsigned long long; using intt = long long; using ll = long long; using ld = long double; const ll m9 = 998244353; const ll m7 = 1000000007; const ll m18 = 1000000000000000000; const ll i127 = 2193062143; const ll l127 = 9187201950435737471; int n, a[5005], x, s[3]; bool used[5005]; void solve(int N) { n=N; int l=1, r=n, mid; while(l<r) { mid=(l+r)>>1; if(query(mid, n)!=n-1) r=mid; else l=mid+1; } a[--l] = 1; used[1]=1; // cerr<<l<<endl; x = query(l,l+1) + 1; a[l+1] = x; used[x]=1; // cerr<<" > "<<x<<endl; if(l!=1) { x = query(l-1,l) + 1; a[l-1] = x; used[x]=1; // cerr<<" < "<<x<<endl; } for(int i=l+2;i<=n;i++) { x=query(i-1,i); // cerr<<x; if(a[i-1]-x<=0 or used[a[i-1]-x]) // + { x=a[i-1]+x; a[i] = x; used[x]=1; } else if(n<a[i-1]+x or used[a[i-1]+x]) { x=a[i-1]-x; a[i] = x; used[x]=1; } else { int y = query(i-2, i); // cerr<<' '<<y<<endl; s[0]=a[i-2]; s[1]=a[i-1]; s[2]=a[i-1]+x; if(*max_element(a,a+3)-*min_element(a,a+3)==y) { x=a[i-1]+x; a[i] = x; used[x]=1; } else { x=a[i-1]-x; a[i] = x; used[x]=1; } } // cerr<<endl; } for(int i=l-2;i>=1;i--) { x=query(i,i+1); // cerr<<x; if(a[i+1]-x<=0 or used[a[i+1]-x]) // + { x=a[i+1]+x; a[i] = x; used[x]=1; } else if(n<a[i+1]+x or used[a[i+1]+x]) { x=a[i+1]-x; a[i] = x; used[x]=1; } else { int y = query(i, i+2); // cerr<<' '<<y<<endl; s[0]=a[i+2]; s[1]=a[i+1]; s[2]=a[i+1]+x; if(*max_element(a,a+3)-*min_element(a,a+3)==y) { x=a[i+1]+x; a[i] = x; used[x]=1; } else { x=a[i+1]-x; a[i] = x; used[x]=1; } } // cerr<<endl; } // for(int i=1;i<=n;i++) cerr<<a[i]<<',';cerr<<endl; for(int i=1;i<=n;i++) answer(i, a[i]); } /* 5 2 1 5 3 4 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...