Submission #1037165

#TimeUsernameProblemLanguageResultExecution timeMemory
1037165modwweStreet Lamps (APIO19_street_lamps)C++17
20 / 100
216 ms8784 KiB
//https://www.instagram.com/_modwwe/ #pragma GCC optimize("Ofast,unroll-loops") //#pragma GCC target("avx2,bmi,bmi2") #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".ans","w",stdout) #define pb push_back #define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; using namespace std; void phongbeo(); const int inf=1e9; const int mod2=1e9+7; const int mod1=998244353; struct icd { int a,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,r,mid,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,l,s33; int i,s10,s12; int kk; int el=29; main() { #ifndef ONLINE_JUDGE // fin(task),fou(task); #endif NHP /// cin>>s1; // modwwe phongbeo(); } string s; int t[100001]; void build(int node,int l,int r) { if(l==r) { t[node]=s[l-1]-'0'; return; }; int mid=l+r>>1; build(node<<1,l,mid); build(node<<1|1,mid+1,r); t[node]=t[node<<1]*t[node<<1|1]; } void upd(int node,int l,int r,int l1) { if(l==r) { t[node]=1-t[node]; return;} int mid=l+r>>1; if(l1<=mid) upd(node<<1,l,mid,l1); else upd(node<<1|1,mid+1,r,l1); t[node]=t[node<<1]*t[node<<1|1]; } int get(int node,int l,int r,int l1,int r1) { if(l>r1||r<l1) return 1; if(l>=l1&&r<=r1) return t[node]; int mid=l+r>>1; return get(node<<1,l,mid,l1,r1)*get(node<<1|1,mid+1,r,l1,r1); } int bsl(int x) { int l=1; int r=x-1; while(l<=r) { int mid=l+r>>1; if(get(1,1,n,mid,x-1)==1) r=mid-1; else l=mid+1; } return r+1; } int bsr(int x) { int l=x+1; int r=n; while(l<=r) { int mid=l+r>>1; if(get(1,1,n,x+1,mid)==1) l=mid+1; else r=mid-1; } return l-1; } struct BIT2D{ int bit[1001][1001]; void up(int x,int y,int z) { for(x;x<=n;x+=x&-x) for(int y2=y;y2<=n;y2+=y2&-y2) bit[x][y2]+=z; } int get(int x,int y) { int ss=0; for(x;x;x-=x&-x) for(int y2=y;y2;y2-=y2&-y2) ss+=bit[x][y2]; return ss; } void upd(int x, int y, int u, int v, int val) { up(x, y, val); up(x, v + 1, -val); up(u + 1, y, -val); up(u + 1, v + 1, val); } }cd; void phongbeo() { cin>>n>>m; cin>>s; build(1,1,n); for(int i=1;i<=m;i++) { string ss2; cin>>ss2; if(ss2[0]=='t'){cin>>l; s2=bsl(l); s3=bsr(l); if(s[l-1]=='1')s[l-1]='0';else s[l-1]='1'; if(s[l-1]=='0') cd.upd(s2,l,l,s3,i); else cd.upd(s2,l,l,s3,-i); upd(1,1,n,l); } else { cin>>l>>r; r--; //cout<<get(1,1,n,l,r),down if(get(1,1,n,l,r)==1)cout<<cd.get(l,r)+i; else cout<<cd.get(l,r); down } } }

Compilation message (stderr)

street_lamps.cpp:49:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   49 | main()
      | ^~~~
street_lamps.cpp: In function 'void build(int, int, int)':
street_lamps.cpp:64:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   64 |       int mid=l+r>>1;
      |               ~^~
street_lamps.cpp: In function 'void upd(int, int, int, int)':
street_lamps.cpp:72:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   72 |       int mid=l+r>>1;
      |               ~^~
street_lamps.cpp: In function 'int get(int, int, int, int, int)':
street_lamps.cpp:81:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   81 |          int mid=l+r>>1;
      |                  ~^~
street_lamps.cpp: In function 'int bsl(int)':
street_lamps.cpp:90:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   90 |             int mid=l+r>>1;
      |                     ~^~
street_lamps.cpp: In function 'int bsr(int)':
street_lamps.cpp:102:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  102 |               int mid=l+r>>1;
      |                       ~^~
street_lamps.cpp: In member function 'void BIT2D::up(int, int, int)':
street_lamps.cpp:112:12: warning: statement has no effect [-Wunused-value]
  112 |        for(x;x<=n;x+=x&-x)
      |            ^
street_lamps.cpp: In member function 'int BIT2D::get(int, int)':
street_lamps.cpp:119:19: warning: statement has no effect [-Wunused-value]
  119 |               for(x;x;x-=x&-x)
      |                   ^
street_lamps.cpp:120:17: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  120 |                 for(int y2=y;y2;y2-=y2&-y2)
      |                 ^~~
street_lamps.cpp:122:19: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  122 |                   return ss;
      |                   ^~~~~~
#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...