제출 #809201

#제출 시각아이디문제언어결과실행 시간메모리
809201Boomyday동굴 (IOI13_cave)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using db = double; using str = string; // yay python! using ii = pair<int,int>; using pl = pair<ll,ll>; using pd = pair<db,db>; using vi = vector<int>; using vb = vector<bool>; using vl = vector<ll>; using vd = vector<db>; using vs = vector<str>; using vii = vector<ii>; using vpl = vector<pl>; using vpd = vector<pd>; #define tcT template<class T #define tcTU tcT, class U tcT> using V = vector<T>; tcT, size_t SZ> using AR = array<T,SZ>; tcT> using PR = pair<T,T>; // pairs #define mp make_pair #define s second #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #define trav(a,x) for (auto& a: x) #define len(x) int((x).size()) #define bg(x) begin(x) #define all(x) bg(x), end(x) #define rall(x) rbegin(x), rend(x) #define sor(x) sort(all(x)) #define rsz resize #define ins insert #define ft front() #define bk back() #define pb push_back #define eb emplace_back #define pf push_front const int MOD = 1e9+7; // 998244353; const int MX = 1e5+5; const ll INF = 1e18; // not too close to LLONG_MAX const ld PI = acos((ld)-1); const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}; // for every grid problem!! /* #include <stdio.h> #include <stdlib.h> #define MAX_N 5000 #define MAX_CALLS 70000 #define fail(s, x...) do { \ fprintf(stderr, s "\n", ## x); \ exit(1); \ } while(0) #define N koala #define realS kangaroo #define realD possum #define inv platypus #define num_calls echidna static int N; static int realS[MAX_N]; static int realD[MAX_N]; static int inv[MAX_N]; static int num_calls; void answer(int S[], int D[]) { int i; int correct = 1; for (i = 0; i < N; ++i) if (S[i] != realS[i] || D[i] != realD[i]) { correct = 0; break; } if (correct) printf("CORRECT\n"); else printf("INCORRECT\n"); for (i = 0; i < N; ++i) { if (i > 0) printf(" "); printf("%d", S[i]); } printf("\n"); for (i = 0; i < N; ++i) { if (i > 0) printf(" "); printf("%d", D[i]); } printf("\n"); exit(0); } int tryCombination(int S[]) { int i; if (num_calls >= MAX_CALLS) { printf("INCORRECT\nToo many calls to tryCombination().\n"); exit(0); } ++num_calls; for (i = 0; i < N; ++i) if (S[inv[i]] != realS[inv[i]]) return i; return -1; } */ void exploreCave(int N) { unordered_set<int> toIgnore; int vals[N]; int doors[N]; vector<int> cands; int cc; F0R(lev,N){ F0R(i,N){ if (toIgnore.find(i)==toIgnore.end()){ cands.pb(i); vals[i]=0; } } if (tryCombination(vals) != lev) { cc=0; } else cc=1; F0R(i,N){ if (toIgnore.find(i)==toIgnore.end()){ vals[i]=cc; } } while (cands.size()>1){ int half = cands.size()/2; vi reject_cands; F0R(i, half){ int x = cands.back(); cands.pop_back(); reject_cands.pb(x); } trav(i, reject_cands) { vals[i] = 1-cc; } if (tryCombination(vals)!=lev){ //success! } else { trav(i, reject_cands) { vals[i]=cc; } trav(i, cands){ vals[i] = 1-cc; } cands = reject_cands; } } toIgnore.insert(cands[0]); doors[cands[0]] = lev; } answer(vals,doors); } #include "cave.h" /* int init() { int i, res; FILE *f = fopen("cave.in", "r"); if (!f) fail("Failed to open input file."); res = fscanf(f, "%d", &N); for (i = 0; i < N; ++i) { res = fscanf(f, "%d", &realS[i]); } for (i = 0; i < N; ++i) { res = fscanf(f, "%d", &realD[i]); inv[realD[i]] = i; } num_calls = 0; return N; } int main() { int N; N = init(); exploreCave(N); printf("INCORRECT\nYour solution did not call answer().\n"); return 0; } */

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

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:158:13: error: 'tryCombination' was not declared in this scope
  158 |         if (tryCombination(vals) != lev) {
      |             ^~~~~~~~~~~~~~
cave.cpp:180:17: error: 'tryCombination' was not declared in this scope
  180 |             if (tryCombination(vals)!=lev){
      |                 ^~~~~~~~~~~~~~
cave.cpp:198:5: error: 'answer' was not declared in this scope
  198 |     answer(vals,doors);
      |     ^~~~~~
In file included from cave.cpp:203:
cave.h: At global scope:
cave.h:10:6: error: conflicting declaration of 'void exploreCave(int)' with 'C' linkage
   10 | void exploreCave(int N);
      |      ^~~~~~~~~~~
cave.cpp:141:6: note: previous declaration with 'C++' linkage
  141 | void exploreCave(int N) {
      |      ^~~~~~~~~~~