제출 #1005759

#제출 시각아이디문제언어결과실행 시간메모리
1005759Br3ad동굴 (IOI13_cave)C++17
컴파일 에러
0 ms0 KiB
#include <iostream> #include <fstream> #include <iomanip> #include <algorithm> #include <functional> #include <numeric> #include <cstring> #include <string> #include <cmath> #include <vector> #include <queue> #include <stack> #include <set> #include <map> using namespace std; #define ll long long #define ull unsigned long long #define f first #define s second #define PF push_front #define PB push_back #define MP make_pair #define max(a, b) ((a > b)? a : b) #define min(a, b) ((a < b)? a : b) #define max3(a, b, c) max(max(a, b), c) #define min3(a, b, c) min(min(a, b), c) const int N = 7e4 + 5; const int M = 1e9 + 7; const int inf = 0x3f3f3f3f; const ll int INF = 1e18; int tryCombination(int S[]); void answer(int S[], int D[]); int* gen(vector<int> v){ int* arr = new int[(int)(v.size())]; for(int i = 0; i < v.size(); i++) arr[i] = v[i]; return arr; } void exploreCave(int n){ auto ans = gen(vector<int>(n, -1)); auto con = gen(vector<int>(n, -1)); // Generate query auto all_on = gen(vector<int>(n, 1)); set<int> remain; for(int i = 0; i < n; i++) remain.insert(i); for(int door = 0; door < n; door++){ // Determine current door correct switch status int val = tryCombination(all_on); bool status = (val > door || val == -1); // Binary search using Binary jumping int pos = n; for(int i = 4096, base = 0; i > 0; i /= 2){ if(base + i > remain.size()) continue; vector<int> temp; for(int j = 0; j < n; j++) temp.PB(ans[j]); int counter = base + i, cur_pos; for(auto j = remain.begin(); j != remain.end(); j++){ temp[*j] = (counter > 0)? status : !status; if(counter > 0) cur_pos = *j; counter--; } auto cur = gen(temp); val = tryCombination(cur); if(val > door || val == -1) pos = min(pos, cur_pos); else base += i; } con[pos] = door; ans[pos] = status; all_on[pos] = status; remain.erase(pos); } answer(ans, con); } int main(){ ios::sync_with_stdio(false); cin.tie(NULL); // ifstream cin(); // ofstream cout(); exploreCave(4); } int tryCombination(int S[]){ for(int i = 0; i < 4; i++){ cout << S[i] << ' '; } cout << endl; int temp; cin >> temp; return temp; } void answer(int S[], int D[]){ for(int i = 0; i < 4; i++){ cout << S[i] << ' '; } cout << endl; for(int i = 0; i < 4; i++){ cout << D[i] << ' '; } cout << endl; }

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

cave.cpp: In function 'int* gen(std::vector<int>)':
cave.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for(int i = 0; i < v.size(); i++) arr[i] = v[i];
      |                    ~~^~~~~~~~~~
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:62:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |             if(base + i > remain.size()) continue;
      |                ~~~~~~~~~^~~~~~~~~~~~~~~
cave.cpp:66:37: warning: 'cur_pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   66 |             int counter = base + i, cur_pos;
      |                                     ^~~~~~~
/usr/bin/ld: /tmp/ccv05Z2z.o: in function `main':
cave.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cctPx5BA.o:grader.c:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cctPx5BA.o: in function `main':
grader.c:(.text.startup+0x10): undefined reference to `exploreCave'
collect2: error: ld returned 1 exit status