제출 #850918

#제출 시각아이디문제언어결과실행 시간메모리
850918promitheas크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++14
5 / 100
248 ms253812 KiB
//CrayfishScrivener/IOI2012 #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <stdint.h> #define MAXNLOG 22 #define MAXN 1000500 class Node { public: char letter; Node* parents[MAXNLOG+1]; int level; Node(Node* parent, char letter = 0) { level = parent ? parent->level + 1 : 0; this->letter = letter; parents[0] = parent; for (int i = 1; i < MAXNLOG; i++) { if (parents[i - 1]) parents[i] = parents[i - 1]->parents[i - 1]; else parents[i] = nullptr; } } Node* GetNthParent(int n) { Node* tar = this; for (int i = MAXNLOG; i >= 0; i--) { int p = 1 << i; if (n & p)tar = tar->parents[i]; if (!tar)return nullptr; } return tar; } }; Node* NODES[MAXN]; int N = 1; void Init() { NODES[0] = nullptr; } void TypeLetter(char L) { NODES[N++] = new Node(NODES[N - 1], L); } void UndoCommands(int U) { NODES[N] = NODES[N++ - U]; } char GetLetter(int L) { int l = NODES[N - 1]->level; return NODES[N - 1]->GetNthParent(l-L)->letter; }

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

scrivener.cpp: In function 'void TypeLetter(char)':
scrivener.cpp:44:9: warning: operation on 'N' may be undefined [-Wsequence-point]
   44 |  NODES[N++] = new Node(NODES[N - 1], L);
      |        ~^~
scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:48:20: warning: operation on 'N' may be undefined [-Wsequence-point]
   48 |  NODES[N] = NODES[N++ - U];
      |                   ~^~
scrivener.cpp:48:20: warning: operation on 'N' may be undefined [-Wsequence-point]
#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...