제출 #537457

#제출 시각아이디문제언어결과실행 시간메모리
537457surguttiWorm Worries (BOI18_worm)C++14
컴파일 에러
0 ms0 KiB
#pragma GCC optimize ("Ofast,inline,unroll-loops") #include <bits/stdc++.h> using namespace std; int N, M, K, Q; vector<int> p{0, 1, 2}; vector<vector<vector<int>>> safe; int get(vector<int> pos, bool print = false) { vector<int> xyz(3); for (int i = 0; i < 3; i++) { xyz[p[i]] = pos[i]; } int x = xyz[0]; int y = xyz[1]; int z = xyz[2]; if (print) { cout << "! " << x << ' ' << y << ' ' << z << endl; return -1; } if (!safe[x][y][z]) { cout << "? " << x << ' ' << y << ' ' << z << endl; cin >> safe[x][y][z]; } return safe[x][y][z]; } int main() { // ios::sync_with_stdio(false), cin.tie(nullptr); cin >> N >> M >> K >> Q; safe.resize(N + 1, vector(M + 1, vector<int>(K + 1))); vector<pair<int, int>> a = {{1, N}, {1, M}, {1, K}}; while (true) { sort(p.begin(), p.end(), [&a](int i, int j) { return a[i].second - a[i].first > a[j].second - a[j].first; }); int max_val = -1; vector<int> max_pos; if (a[p[0]].second - a[p[0]].first <= 2) { for (int i = a[p[0]].first; i <= a[p[0]].second; i++) { for (int j = a[p[1]].first; j <= a[p[1]].second; j++) { for (int k = a[p[2]].first; k <= a[p[2]].second; k++) { int cur_val =#pragma GCC optimize ("Ofast,inline,unroll-loops") #include <bits/stdc++.h> using namespace std; int N, M, K, Q; vector<int> p{0, 1, 2}; vector<vector<vector<int>>> safe; int get(vector<int> pos, bool print = false) { vector<int> xyz(3); for (int i = 0; i < 3; i++) { xyz[p[i]] = pos[i]; } int x = xyz[0]; int y = xyz[1]; int z = xyz[2]; if (print) { cout << "! " << x << ' ' << y << ' ' << z << endl; return -1; } if (!safe[x][y][z]) { cout << "? " << x << ' ' << y << ' ' << z << endl; cin >> safe[x][y][z]; } return safe[x][y][z]; } int main() { // ios::sync_with_stdio(false), cin.tie(nullptr); cin >> N >> M >> K >> Q; safe.resize(N + 1, vector(M + 1, vector<int>(K + 1))); vector<pair<int, int>> a = {{1, N}, {1, M}, {1, K}}; while (true) { sort(p.begin(), p.end(), [&a](int i, int j) { return a[i].second - a[i].first > a[j].second - a[j].first; }); int max_val = -1; vector<int> max_pos;        if (a[p[0]].second - a[p[0]].first <= 2) { for (int i = a[p[0]].first; i <= a[p[0]].second; i++) { for (int j = a[p[1]].first; j <= a[p[1]].second; j++) { for (int k = a[p[2]].first; k <= a[p[2]].second; k++) { int cur_val = get({i, j, k}); if (cur_val > max_val) { max_val = cur_val; max_pos = {i, j, k}; } } } } get(max_pos, true); return 0; } int m = (a[p[0]].first + a[p[0]].second) >> 1; for (int i = a[p[1]].first; i <= a[p[1]].second; i++) { for (int j = a[p[2]].first; j <= a[p[2]].second; j++) { int cur_val = get({m, i, j}); if (cur_val > max_val) { max_val = cur_val; max_pos = {m, i, j}; } } } vector<int> L_pos = max_pos; vector<int> R_pos = max_pos; L_pos[0]--; R_pos[0]++; if (get(L_pos) < get(R_pos)) { a[p[0]].first = m; } else { a[p[0]].second = m; } } } get({i, j, k}); if (cur_val > max_val) { max_val = cur_val; max_pos = {i, j, k}; } } } } get(max_pos, true); return 0; } int m = (a[p[0]].first + a[p[0]].second) >> 1; for (int i = a[p[1]].first; i <= a[p[1]].second; i++) { for (int j = a[p[2]].first; j <= a[p[2]].second; j++) { int cur_val = get({m, i, j}); if (cur_val > max_val) { max_val = cur_val; max_pos = {m, i, j}; } } } vector<int> L_pos = max_pos; vector<int> R_pos = max_pos; L_pos[0]--; R_pos[0]++; if (get(L_pos) < get(R_pos)) { a[p[0]].first = m; } else { a[p[0]].second = m; } } }

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

worm.cpp:60:38: error: stray '#' in program
   60 |                         int cur_val =#pragma GCC optimize ("Ofast,inline,unroll-loops")
      |                                      ^
worm.cpp:114:2: error: extended character   is not valid in an identifier
  114 |         if (a[p[0]].second - a[p[0]].first <= 2) {
      |  ^
worm.cpp:114:5: error: extended character   is not valid in an identifier
  114 |         if (a[p[0]].second - a[p[0]].first <= 2) {
      |    ^
worm.cpp:114:8: error: extended character   is not valid in an identifier
  114 |         if (a[p[0]].second - a[p[0]].first <= 2) {
      |      ^
worm.cpp:114:11: error: extended character   is not valid in an identifier
  114 |         if (a[p[0]].second - a[p[0]].first <= 2) {
      |        ^
worm.cpp: In function 'int main()':
worm.cpp:42:30: error: missing template arguments before '(' token
   42 |     safe.resize(N + 1, vector(M + 1, vector<int>(K + 1)));
      |                              ^
worm.cpp:60:39: error: 'pragma' was not declared in this scope; did you mean '_Pragma'?
   60 |                         int cur_val =#pragma GCC optimize ("Ofast,inline,unroll-loops")
      |                                       ^~~~~~
      |                                       _Pragma
worm.cpp:71:46: error: a function-definition is not allowed here before '{' token
   71 | int get(vector<int> pos, bool print = false) {
      |                                              ^
worm.cpp:96:12: error: a function-definition is not allowed here before '{' token
   96 | int main() {
      |            ^
worm.cpp:65:5: warning: unused variable 'N' [-Wunused-variable]
   65 | int N, M, K, Q;
      |     ^
worm.cpp:65:8: warning: unused variable 'M' [-Wunused-variable]
   65 | int N, M, K, Q;
      |        ^
worm.cpp:65:11: warning: unused variable 'K' [-Wunused-variable]
   65 | int N, M, K, Q;
      |           ^
worm.cpp:65:14: warning: unused variable 'Q' [-Wunused-variable]
   65 | int N, M, K, Q;
      |              ^