# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
432844 | 2021-06-18T14:08:49 Z | Amylopectin | Street Lamps (APIO19_street_lamps) | C++14 | 405 ms | 31116 KB |
#include <iostream> #include <stdio.h> #include <vector> using namespace std; const int mxn = 800010,mxi = 1e9 + 10; char s[mxn] = {},inp[mxn] = {}; struct we { int tim,sta; }; vector<struct we> li[mxn] = {}; //struct we li[mxn][mxn] = {}; int coun[mxn] = {},cva[mxn] = {},se[mxn] = {}; int fima(int l,int r) { if(l > r) return l; return r; } int cre(int cl,int cr,int no) { if(cl == cr) { se[no] = mxi; return 0; } int mid = (cl + cr) / 2; cre(cl,mid,no*2); cre(mid+1,cr,no*2+1); se[no] = mxi; return 0; } int ins(int cl,int cr,int no,int tn,int iva) { if(cr < tn || cl > tn) { // se[no] = iva; return 0; } if(cl == cr) { se[no] = iva; return 0; } int mid = (cl + cr) / 2; ins(cl,mid,no*2,tn,iva); ins(mid+1,cr,no*2+1,tn,iva); se[no] = fima(se[no*2],se[no*2+1]); return 0; } int firma(int cl,int cr,int no,int tl,int tr) { if(cr < tl || cl > tr) { return 0; } if(cl >= tl && cr <= tr) { return se[no]; } int mid = (cl + cr) / 2,cma = 0; cma = fima(cma,firma(cl,mid,no*2,tl,tr)); cma = fima(cma,firma(mid+1,cr,no*2+1,tl,tr)); // se[no] = fima(se[no*2],se[no*2+1]); return cma; } int main() { int i,j,n,m,q,f,t,cst,cou,su,k; scanf("%d %d %s",&n,&q,&s); cre(0,n-1,1); for(i=0; i<n; i++) { // li[i][0] = {0,s[i] - '0'}; // li[i].push_back({0,s[i] - '0'}); if(s[i] == '1') { ins(0,n-1,1,i,0); } // coun[i] = 1; } for(i=1; i<=q; i++) { scanf("%s",&inp); if(inp[0] == 't') { scanf("%d",&f); f --; ins(0,n-1,1,f,i); // if(li[f][li[f].size()-1].sta == 1) // { // cva[f] += i - li[f][li[f].size()-1].tim; // } // li[f].push_back({i,(li[f][li[f].size()-1].sta + 1) % 2}); // li[f][coun[f]] = {i,(li[f][coun[f]-1].sta + 1) % 2}; // coun[f] ++; } else { scanf("%d %d",&f,&t); f --; t --; su = firma(0,n-1,1,f,t-1); if(su == mxi) { su = 0; } else { su = i-su; } // su = cva[f]; // if(li[f][li[f].size()-1].sta == 1) // { // su += i - li[f][li[f].size()-1].tim; // } // for(j=1; j<=i; j++) // { // cva[j] = 1; // } // for(j=f; j<t; j++) // { // cst = li[j][0].sta; // cou = 1; //// cva[0] &= cst; // for(k=1; k<=i; k++) // { // cva[k] &= cst; // if(cou < coun[j] && li[j][cou].tim == k) // { // cst = (cst+1) % 2; // cou ++; // } // } // } // su = 0; // for(k=1; k<=i; k++) // { // su += cva[k]; // } printf("%d\n",su); } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 19020 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 134 ms | 19504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 19108 KB | Output is correct |
2 | Correct | 13 ms | 19020 KB | Output is correct |
3 | Correct | 13 ms | 19064 KB | Output is correct |
4 | Correct | 13 ms | 19020 KB | Output is correct |
5 | Correct | 195 ms | 27572 KB | Output is correct |
6 | Correct | 256 ms | 28336 KB | Output is correct |
7 | Correct | 325 ms | 29124 KB | Output is correct |
8 | Correct | 405 ms | 31116 KB | Output is correct |
9 | Correct | 132 ms | 22852 KB | Output is correct |
10 | Correct | 146 ms | 22980 KB | Output is correct |
11 | Correct | 142 ms | 23260 KB | Output is correct |
12 | Correct | 329 ms | 29616 KB | Output is correct |
13 | Correct | 394 ms | 31044 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 19020 KB | Output is correct |
2 | Incorrect | 13 ms | 19048 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 19020 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |