제출 #1081599

#제출 시각아이디문제언어결과실행 시간메모리
1081599kustizus도서관 (JOI18_library)C++17
컴파일 에러
0 ms0 KiB
// #pragma GCC optimize("O3","unroll-loops") #include <bits/stdc++.h> #include "library.h" using namespace std; // #define #define int long long #define all(v) v.begin(), v.end() #define fi first #define se second mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); // declare void Solve(int n) { int idx; vector <int> m(n, 1); for (int i = 1; i <= n; ++i) { m[i - 1] = 0; int ans = Query(m); if (ans == 1) { idx = i; break; } } vector <int> ans = {idx}; vector <bool> vs(n, false); for (int i = 1; i < n; ++i){ vs[idx - 1] = true; vector <int> now; for (int j = 0; j < n; ++j) if (!vs[j]) now.push_back(j); int l = 1, r = now.size(); while (l < r){ int md = l + r >> 1; vector <int> m(n, 0); for (int i = l; i <= md; ++i) m[now[i - 1] - 1] = 1; int c1 = Query(m); m[idx - 1] = 1; int c2 = Query(m); if (c1 == c2) r = md; else l = md + 1; } ans.push_back(now[l - 1]); idx = now[l - 1]; } Answer(ans); }

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

library.cpp: In function 'void Solve(long long int)':
library.cpp:22:25: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   22 |         int ans = Query(m);
      |                         ^
In file included from library.cpp:3:
library.h:2:35: note: in passing argument 1 of 'int Query(const std::vector<int>&)'
    2 | int Query(const std::vector<int>& M);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~^
library.cpp:39:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   39 |             int md = l + r >> 1;
      |                      ~~^~~
library.cpp:43:28: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   43 |             int c1 = Query(m);
      |                            ^
In file included from library.cpp:3:
library.h:2:35: note: in passing argument 1 of 'int Query(const std::vector<int>&)'
    2 | int Query(const std::vector<int>& M);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~^
library.cpp:45:28: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   45 |             int c2 = Query(m);
      |                            ^
In file included from library.cpp:3:
library.h:2:35: note: in passing argument 1 of 'int Query(const std::vector<int>&)'
    2 | int Query(const std::vector<int>& M);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~^
library.cpp:52:12: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   52 |     Answer(ans);
      |            ^~~
In file included from library.cpp:3:
library.h:3:37: note: in passing argument 1 of 'void Answer(const std::vector<int>&)'
    3 | void Answer(const std::vector<int>& res);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~