Submission #935869

#TimeUsernameProblemLanguageResultExecution timeMemory
935869PagodePaiva크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
34 / 100
1067 ms16032 KiB
#include<bits/stdc++.h>
#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];
}

Compilation message (stderr)

scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:36:17: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   36 |   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...