제출 #607661

#제출 시각아이디문제언어결과실행 시간메모리
607661jairRS동굴 (IOI13_cave)C++17
21 / 100
99 ms340 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; using vi = vector<int>; const int MAXN = 5'000; int switches[MAXN]; // door triggered by switchID int door[MAXN]; int gN; // returns N instead of -1 when all doors are open int getLastDoor() { int lastDoor = tryCombination(switches); if (lastDoor == -1) lastDoor = gN; return lastDoor; } void exploreCave(int N) { gN = N; // doors up to curDoor EXCEPT curDoor are open for (int curDoor = 0; curDoor < N; curDoor++) { int lastDoor = getLastDoor(); int doorOpen = lastDoor > curDoor; int respSwitch; for (int s = 0; s < N; s++) { switches[s] = !switches[s]; int queryLastDoor = getLastDoor(); switches[s] = !switches[s]; if (doorOpen) { if (queryLastDoor == curDoor) respSwitch = s; } else if (queryLastDoor > curDoor) respSwitch = s; } door[respSwitch] = curDoor; if (!doorOpen) switches[respSwitch] = !switches[respSwitch]; } answer(switches, door); }

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

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:51:34: warning: 'respSwitch' may be used uninitialized in this function [-Wmaybe-uninitialized]
   51 |             switches[respSwitch] = !switches[respSwitch];
      |             ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#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...