Submission #1143491

#TimeUsernameProblemLanguageResultExecution timeMemory
1143491modwweMonster Game (JOI21_monster)C++20
92 / 100
27 ms432 KiB
/// try my best #include "monster.h" #include<bits/stdc++.h> //#define int long long #define ll long long #define down cout<<'\n'; #define debug cout<<" cucuucucuuu",down #define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); #define modwwe int t;cin>>t; while(t--) #define bit(i,j) (i>>j&1) #define sobit(a) __builtin_popcountll(a) #define task2 "ftree" #define task "test" #define fin(x) freopen(x".inp","r",stdin) #define fou(x) freopen(x".out","w",stdout) #define pb push_back #define mask(k) (1<<k) #define mp make_pair #define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; using namespace std; #define getchar_unlocked getchar mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); inline int scan() { char c = getchar_unlocked(); int x = 0; while (c < '0' || c > '9') { c = getchar_unlocked(); } while (c >= '0' && c <= '9') { x = (x << 1) + (x << 3) + c - '0'; c = getchar_unlocked(); } return x; } void phongbeo(); const int inf = 1e16; const ll mod2 = 1e9+7; const int mod1 = 998244353; const ll base=67; int add(int x,int y) { if(x+y>=mod2) x-=mod2; if(x+y<0)x+=mod2; return x+y; } struct icd { long double a; int b; }; struct ib { int a; int b; }; struct ic { int a,b,c; }; struct id { int a, b, c, d; }; struct ie { int a, b, c, d, e; }; ll n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2, r2, center; ll i, s10, s12,k1,k2,k3,s11,lim,w,l,r ; ll kk; ll el = 19;/* main() { if(fopen(task2".inp","r")) { fin(task2); fou(task2); } if(fopen(task".inp","r")) { fin(task); fou(task); } NHP /// cin>>s1; //modwwe phongbeo(),down // checktime }*/ /// read sol /// code trâu ra nhân xét /// [1,0] [3,2,1] [7,6,5,4] /// vì giả sử [1,0] [3,2] thì 1 sẽ chỉ còn lớn hơn 2 nên bắt buộc phải 1 vector<int> h,a;/* bool Query(int x, int y) { if(abs(h[x]-h[y])==1)return h[x]<h[y]; return h[x]>h[y]; }*/ int cast(int y) { dem=0; for(int i=0; i<n; i++) { if(i==y) continue; dem+=Query(a[y],a[i]); } return dem; } vector<int> Solve(int N) {n=N; if(n==1) return a; vector<int> kk; for(int i=0;i<n;i++) kk.pb(i); shuffle(kk.begin(),kk.end(),rd); a.pb(kk[0]); for(int i=1; i<n; i++) { l=0; r=a.size()-1; while(l<=r) { int mid=l+r>>1; if(Query(kk[i],a[mid])) l=mid+1; else r=mid-1; } a.insert(a.begin()+l,kk[i]); } int hihi; s2=cast(0); if(s2==1) { s3=cast(1); if(s3==1)hihi=1; else hihi=0; } else { hihi=s2; } int start=0; vector<int> ans; ans.resize(n); while(start<n) { for(int j=start; j<=hihi; j++) ans[a[j]]=start-j+hihi; int dd=hihi+1; while(dd<n&&Query(a[dd],a[start]))dd++; start=hihi+1; hihi=dd; } return ans; } void phongbeo() { cin>>n; for(int i=0; i<n; i++) cin>>s2,h.pb(s2);/* for(int i=1; i<=n; i++) h.pb(i); shuffle(h.begin(),h.end(),rd); */ dem=0; vector<int> k=Solve(n); dem=0; for(auto x:k) { cout<<x,down if(x!=h[dem]) { for(auto f:h) cout<<f<<" "; down } dem++; } }

Compilation message (stderr)

monster.cpp:39:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+16' to '2147483647' [-Woverflow]
   39 | const int inf = 1e16;
      |                 ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...