제출 #590740

#제출 시각아이디문제언어결과실행 시간메모리
590740l_rehoMemory (IOI10_memory)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; map<char, int> mp; vector<bool> open(51, false); char faceup(int C); void play() { int prev_open = -1; for(int i = 1; i <= 50; i++){ char c = faceup(i); int idxC = mp[c]; // se ne ho già trovata una di c ed è aperta, allora // basta cosi if(idxC && open[idxC]){ open[idxC] = 0; prev_open = -1; continue; } // se ne ho già trovata una di c e non è aperta, allora // se ce ne sono altre aperte, allora devo riaprire la corrente e quella precedentemente trovata if(idxC && !open[idxC]){ if(prev_open != -1){ open[prev_open] = 0; faceup(i); faceup(idxC); }else faceup(idxC); continue; } // se non ho trovato c e non ho altre aperte dietro, allora i rimane aperta if(!idxC && prev_open == -1){ prev_open = i; open[i] = 1; mp[c] = i; continue; } // se non ho trovato c e ne ho altre aperte dietro, allora i si chiude insieme a quell'altra if(!idxC && prev_open != -1){ open[prev_open] = 0; open[i] = 0; mp[c] = i; prev_open = -1; } } } char faceup(int C){ int c0, c1; if (C < 1 || C > 50 || is_up[C]) { exit(92); } is_up[C] = 1; up[moves%2] = C; moves++; if (moves%2 == 0) { c0 = card[ up[0] ] - 'A'; c1 = card[ up[1] ] - 'A'; if (c0==c1 && !candy[c0]) { candy[c0] = 1; ++candies; } is_up[ up[0] ] = is_up[ up[1] ] = 0; } return card[C]; } void playgame(){ int i; for (i=1;i<=50;i++) { card[i] = getchar(); } moves = candies = 0; play(); if (candies != 25) { cout<<candies<<endl; exit(91); } }

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

memory.cpp: In function 'char faceup(int)':
memory.cpp:70:27: error: 'is_up' was not declared in this scope
   70 |    if (C < 1 || C > 50 || is_up[C]) {
      |                           ^~~~~
memory.cpp:73:4: error: 'is_up' was not declared in this scope
   73 |    is_up[C] = 1;
      |    ^~~~~
memory.cpp:74:4: error: 'up' was not declared in this scope; did you mean 'mp'?
   74 |    up[moves%2] = C;
      |    ^~
      |    mp
memory.cpp:74:7: error: 'moves' was not declared in this scope
   74 |    up[moves%2] = C;
      |       ^~~~~
memory.cpp:77:12: error: 'card' was not declared in this scope
   77 |       c0 = card[ up[0] ] - 'A';
      |            ^~~~
memory.cpp:79:22: error: 'candy' was not declared in this scope
   79 |       if (c0==c1 && !candy[c0]) {
      |                      ^~~~~
memory.cpp:81:12: error: 'candies' was not declared in this scope
   81 |          ++candies;
      |            ^~~~~~~
memory.cpp:85:11: error: 'card' was not declared in this scope
   85 |    return card[C];
      |           ^~~~
memory.cpp: In function 'void playgame()':
memory.cpp:91:7: error: 'card' was not declared in this scope
   91 |       card[i] = getchar();
      |       ^~~~
memory.cpp:93:4: error: 'moves' was not declared in this scope
   93 |    moves = candies = 0;
      |    ^~~~~
memory.cpp:93:12: error: 'candies' was not declared in this scope
   93 |    moves = candies = 0;
      |            ^~~~~~~