제출 #70820

#제출 시각아이디문제언어결과실행 시간메모리
70820MANcity크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++14
컴파일 에러
0 ms0 KiB
#include<iostream> #include<cstdio> #include<fstream> #include<algorithm> #include<cmath> #include<map> #include<queue> #include<set> #include<stack> #include<string> #include<cstring> #include<vector> using namespace std; #define for1(i,n) for(int i=1;i<=(int)n;i++) #define for0(i,n) for(int i=0;i<=(int)n;i++) #define forn(i,n) for(int i=n;i>=1;i--) #define fo(i,x,y) for(int i=x;i<=(int)y;i++) #define fr(i,x,y) for(int i=x;i>=(int)y;i--) #define pb push_back #define mp make_pair #define LL long long const LL Mod=1000*1000*1000+7; char last; int OP_NOW; int letter_par[1000002]; int up[1000002][30]; int height[1000002]; int maxhi=0; void Init() {} void TypeLetter(char L) { OP_NOW++; letter_par[OP_NOW]=(L-'a'); height[OP_NOW]=height[OP_NOW-1]+1; maxhi=max(maxhi,height[OP_NOW]); up[OP_NOW][0]=(OP_NOW-1); for1(i,log2(4*maxhi)); up[OP_NOW][i]=up[up[OP_NOW][i-1]][i-1]; } void UndoCommands(int U) { OP_NOW++; height[OP_NOW]=height[OP_NOW-U-1]; letter_par[OP_NOW]=letter_par[OP_NOW-U-1]; for0(i,log2(4*maxhi)) up[OP_NOW][i]=up[OP_NOW-U-1][i]; } char GetLetter(int P) { int N=height[OP_NOW]; if((P+1)==height[OP_NOW]) { return (letter_par[OP_NOW]+'a'); } int pos=OP_NOW; //cout<<pos<<" "<<up[pos][0]<<" "<<up[pos][1]<<" "<<up[pos][2]<<" "<<up[pos][3]<<endl; fr(i,log2(4*maxhi),0) { //cout<<up[pos][i]<<" "<<height[up[pos][i]]<<endl; if(height[up[pos][i]]>=(P+1)) { //cout<<i<<"dddd"<<endl; pos=up[pos][i]; } } return (letter_par[pos]+'a'); } /* 1000 T a T b T d P 1 */

컴파일 시 표준 에러 (stderr) 메시지

scrivener.cpp: In function 'void TypeLetter(char)':
scrivener.cpp:14:19: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
 #define for1(i,n) for(int i=1;i<=(int)n;i++)
                   ^
scrivener.cpp:37:5: note: in expansion of macro 'for1'
     for1(i,log2(4*maxhi));
     ^~~~
scrivener.cpp:38:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
         up[OP_NOW][i]=up[up[OP_NOW][i-1]][i-1];
         ^~
scrivener.cpp:38:20: error: 'i' was not declared in this scope
         up[OP_NOW][i]=up[up[OP_NOW][i-1]][i-1];
                    ^
scrivener.cpp: In function 'char GetLetter(int)':
scrivener.cpp:50:9: warning: unused variable 'N' [-Wunused-variable]
     int N=height[OP_NOW];
         ^