Submission #1100047

#TimeUsernameProblemLanguageResultExecution timeMemory
1100047modwweSushi (JOI16_sushi)C++17
100 / 100
5185 ms153004 KiB
#pragma GCC optimize("Ofast,unroll-loops") //#pragma GCC optimize("conserve-stack") #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 task "test" #define fin(x) freopen(x".inp","r",stdin) #define fou(x) freopen(x".out","w",stdout) #define pb push_back #define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; using namespace std; #define getchar_unlocked getchar 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 = 1e18; const int mod2 = 1e9 + 7; const int mod1 = 998244353; 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; }; int n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, l, r, mid, l2, r2, center; int i, s10, s12,k1,k2,k3,s11,t,lim,w; int kk; int el = 19; main() { if(fopen(task".inp","r")) { fin(task); fou(task); } NHP /// cin>>s1; ///modwwe phongbeo(); // checktime } vector<int> v[670]; struct chiacan { vector<int> a; int sz=0; priority_queue<int,vector<int>,greater<int>>p; priority_queue<int,vector<int>>p2; void init(vector<int> v) { a.resize(v.size()+1); sz=v.size(); for(int i=1; i<=v.size(); i++) a[i]=v[i-1],p2.push(a[i]); } int upd(int x) { p.push({x}); if(p2.top()>x) { int ff=p2.top(); p2.pop(); p2.push(x); x=ff; } return x; } int reset(int l,int r,int y) { for(int i=1; i<=sz; i++) { if(!p.empty()&&a[i]>p.top()) { int ff=a[i]; a[i]=p.top(); p.pop(); p.push(ff); } } while(!p.empty()) p.pop(); while(!p2.empty()) p2.pop(); for(int i=l; i<=r; i++) { if(a[i]>y) { swap(a[i],y); } } for(int i=1; i<=sz; i++) p2.push({a[i]}); return y; } } bucket[670]; int S=634 ; int upd(int l,int r,int x) { if(l==0) l2=0; else l2=(l-1)/S+1; s10=-1; if(l%S!=0) { x=bucket[l/S].reset(l%S+1,min(l-l%S+S-1,r)%S+1,x); s10=min(l-l%S+S-1,r); } r2=(r+1)/S-1; for(int j=l2; j<=r2; j++) x=bucket[j].upd(x); if(s10!=r&&(r+1)%S!=0) { x=bucket[r/S].reset(1,r%S+1,x); } return x; } void phongbeo() { cin>>n>>m; v[0].pb(0); for(int i=1; i<=n; i++) { cin>>l; v[i/S].pb(l); } for(int i=0; i<=n/S; i++) bucket[i].init(v[i]); for(int i=1; i<=m; i++) { cin>>l>>r>>s2; if(l<=r) cout<<upd(l,r,s2); else { s2=upd(l,n,s2); cout<<upd(0,r,s2); } down } } //6 0 0 0 6 0 0

Compilation message (stderr)

sushi.cpp:69:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   69 | main()
      | ^~~~
sushi.cpp: In member function 'void chiacan::init(std::vector<long long int>)':
sushi.cpp:93:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   93 |         for(int i=1; i<=v.size(); i++)
      |                      ~^~~~~~~~~~
sushi.cpp: In function 'int main()':
sushi.cpp:13:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define fin(x) freopen(x".inp","r",stdin)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~
sushi.cpp:73:9: note: in expansion of macro 'fin'
   73 |         fin(task);
      |         ^~~
sushi.cpp:14:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 | #define fou(x) freopen(x".out","w",stdout)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~
sushi.cpp:74:9: note: in expansion of macro 'fou'
   74 |         fou(task);
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...