Submission #154835

#TimeUsernameProblemLanguageResultExecution timeMemory
154835AkashiStreet Lamps (APIO19_street_lamps)C++14
Compilation error
0 ms0 KiB
///o points code, sent just to save #include <bits/stdc++.h> using namespace std; struct node{ int Sum; int Lazy; node *left, *right; nod(){ Sum = 0; Lazy = -1; left = right = NULL; } }; node *Arb[1200005]; int val[1200005]; int n, m; int a[300005]; char s[300005], c[205]; void buildy(int val, int nod){ Arb[nod] = new node; Arb[nod]->Sum = m * val; Arb[nod]->Lazy = val; } void buildx(int st = 1, int dr = n, int nod = 1){ if(st == dr){ buildy(a[st] > 0, nod); val[nod] = a[st] > 0; return ; } int mij = (st + dr) / 2; buildx(st, mij, nod * 2); buildx(mij + 1, dr, nod * 2 + 1); val[nod] = val[nod * 2] & val[nod * 2 + 1]; buildy(val[nod], nod); } void give_val(int v, int st, int dr, node* nod){ if(v == 0) nod->Lazy = 0, nod->Sum = 0; else{ nod->Lazy = 1; nod->Sum = dr - st + 1; } } void propag(node* nod, int st, int mij, int dr){ if(nod->left == NULL) nod->left = new node; if(nod->right == NULL) nod->right = new node; if(nod->Lazy != -1){ give_val(nod->Lazy, st, mij, nod->left); give_val(nod->Lazy, mij + 1, dr, nod->right); nod->Lazy = -1; } } void updatey(int v, int x, int y, node *nod, int st = 1, int dr = n){ if(x <= st && dr <= y){ give_val(v, st, dr, nod); return ; } int mij = (st + dr) / 2; propag(nod, st, mij, dr); if(x <= mij) updatey(v, x, y, nod->left); if(mij + 1 <= y) updatey(v, x, y, nod->right); nod->Sum = nod->left->Sum + nod->right->Sum; } void updatex(int x, int tmp, int st = 1, int dr = n, int nod = 1){ if(st == dr){ updatey(a[x] > 0, tmp, m, Arb[nod]); val[nod] = a[x] > 0; return ; } int mij = (st + dr) / 2; if(x <= mij) updatex(x, tmp, st, mij, nod * 2); else updatex(x, tmp, mij + 1, dr, nod * 2 + 1); val[nod] = val[nod * 2] & val[nod * 2 + 1]; updatey(val[nod], tmp, m, Arb[nod]); } int queryy(int x, int y, int nod, ) int queryx(int x, int y, int tmp, int st = 1, int dr = n, int nod = 1){ if(x <= st && dr <= y) return queryy(1, tmp, Arb[nod]); int mij = (st + dr) / 2, v1 = 0, v2 = 0; if(x <= mij) v1 = queryx(x, y, tmp, st, mij, nod * 2); if(mij + 1 <= y) v2 = queryx(x, y, tmp, mij + 1, dr, nod * 2 + 1); return v1 + v2; } int main() { scanf("%d%d", &n, &m); scanf("%s", s + 1); for(int i = 1; i <= n ; ++i){ a[i] += s[i] - '0'; a[i + 1] += s[i] - '0'; } buildx(); int i, x, y; for(int tmp = 1; tmp <= m ; ++tmp){ scanf("%s", c); if(c[0] == 'q'){ scanf("%d%d", &x, &y); printf("%d\n", queryx(x, y, tmp)); } else{ scanf("%d", &i); a[i] -= s[i] - '0'; a[i + 1] -= s[i] - '0'; s[i] = '1' - s[i]; a[i] += s[i] - '0'; a[i + 1] += s[i] - '0'; updatex(i, tmp); updatex(i + 1, tmp); } } return 0; }

Compilation message (stderr)

street_lamps.cpp:11:9: error: ISO C++ forbids declaration of 'nod' with no type [-fpermissive]
     nod(){
         ^
street_lamps.cpp: In member function 'int node::nod()':
street_lamps.cpp:14:5: warning: no return statement in function returning non-void [-Wreturn-type]
     }
     ^
street_lamps.cpp: At global scope:
street_lamps.cpp:96:35: error: expected identifier before ')' token
 int queryy(int x, int y, int nod, )
                                   ^
street_lamps.cpp:98:1: error: expected initializer before 'int'
 int queryx(int x, int y, int tmp, int st = 1, int dr = n, int nod = 1){
 ^~~
street_lamps.cpp: In function 'int main()':
street_lamps.cpp:126:28: error: 'queryx' was not declared in this scope
             printf("%d\n", queryx(x, y, tmp));
                            ^~~~~~
street_lamps.cpp:110:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
street_lamps.cpp:111:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", s + 1);
     ~~~~~^~~~~~~~~~~~~
street_lamps.cpp:122:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s", c);
         ~~~~~^~~~~~~~~
street_lamps.cpp:124:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d%d", &x, &y);
             ~~~~~^~~~~~~~~~~~~~~~
street_lamps.cpp:129:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &i);
             ~~~~~^~~~~~~~~~