Submission #218978

#TimeUsernameProblemLanguageResultExecution timeMemory
218978KoalaMuchCrayfish scrivener (IOI12_scrivener)C++14
Compilation error
0 ms0 KiB
//#include "grader.cpp" #include<bits/stdc++.h> using namespace std; const int N = 1e6+5; struct A { int l,r; char C; }; A sm[N*30]; int root[N]; int cur; int n; int len[N]; int opr; int clone(int idx) {sm[++cur] = sm[idx];return cur;} int update(int l,int r,int idx,int now,char v) { int newnode = clone(now); if(l==r) { sm[newnode].C = v; return newnode; } int mid = (l+r) >> 1; sm[newnode].r = update(mid+1,r,idx,sm[newnode].r,v); return newnode; } char query(int l,int r,int now,int idx) { if(l==r) return sm[now].C; int mid = (l+r) >> 1; if(idx<=mid) return query(l,mid,sm[now].l,idx); return query(mid+1,r,sm[now].r,idx); } void Init() {} void TypeLetter(char L) { ++opr; ++n; len[opr] = n; root[opr] = update(0,n-1,n-1,root[opr-1],L); } void UndoCommands(int U) { ++opr; len[opr] = n = len[max(0,opr-U-1)]; root[opr] = root[max(0,opr-U-1)]; } char GetLetter(int P) { return query(0,n-1,root[opr],P); } int main() { while(1) { int cmd,U,P; char L; scanf("%d",&cmd); if(cmd==1) scanf(" %c",&L),TypeLetter(L); else if(cmd==2) scanf("%d",&U),UndoCommands(U); else scanf("%d",&P),printf("%c\n",GetLetter(P)); } } /* 1 a 1 b 3 1 1 d 2 2 2 1 3 2 1 e 2 1 2 5 1 c 3 2 2 2 3 2 */

Compilation message (stderr)

scrivener.cpp: In function 'int main()':
scrivener.cpp:57:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&cmd);
         ~~~~~^~~~~~~~~~~
scrivener.cpp:58:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         if(cmd==1)  scanf(" %c",&L),TypeLetter(L);
                     ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
scrivener.cpp:59:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         else if(cmd==2) scanf("%d",&U),UndoCommands(U);
                         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
scrivener.cpp:60:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         else            scanf("%d",&P),printf("%c\n",GetLetter(P));
                         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/ccZOK4ne.o: In function `main':
scrivener.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccJpZ2fZ.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status