제출 #935895

#제출 시각아이디문제언어결과실행 시간메모리
935895PagodePaiva크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
34 / 100
1072 ms15648 KiB
#include<bits/stdc++.h>
#pragma GCC optimize("03")
#pragma GCC optimization("0fast")
#define N 1000005

using namespace std;

int pai[N], h[N], jump[N], pos[N];
char letter[N];
int t;

void Init() {
  t = 0;
}

void TypeLetter(char L) {
  t++;
  pai[t] = t-1;
  h[t] = h[t-1] + 1;
  letter[t] = L;
  pos[t] = pos[t-1]+1;
  int p = t-1;
  if(h[jump[p]] - h[p] == h[jump[jump[p]]] - h[jump[p]]){
    jump[t] = jump[jump[p]];
  }
  else{
    jump[t] = p;
  }
}

void UndoCommands(int U) {
  t++;
  pai[t] = t-U-1;
  int p = pai[t];
  h[t] = h[pai[t]] + 1;
  letter[t] = letter[p];
  pos[t] = pos[p];
  if(h[jump[p]] = h[p] == h[jump[jump[p]]] - h[jump[p]]){
    jump[t] = jump[jump[p]];
  }
  else{
    jump[t] = p;
  }
}

char GetLetter(int P) {
  P++;
  int v = t;
  while(pos[v] > P){
    if(pos[jump[v]] < P){
      v = pai[v];
    }
    else{
      v = jump[v];
    }
  }
  return letter[v];
}

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

scrivener.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    3 | #pragma GCC optimization("0fast")
      | 
scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:38:17: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   38 |   if(h[jump[p]] = h[p] == h[jump[jump[p]]] - h[jump[p]]){
      |      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...