제출 #131808

#제출 시각아이디문제언어결과실행 시간메모리
131808apostoldaniel854Triangles (CEOI18_tri)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; bool cmp (int a, int b) { return is_clockwise (n, a, b); } const int N = 1e5; int idx[1 + N]; #define pb push_back int main () { int n = get_n (); vector <int> x, y; for (int i = 2; i < n; i++) if (is_clockwise (n, i, 1)) x.pb (i); else y.pb (i); sort (x.begin (), x.end (), cmp); sort (y.begin (), y.end (), cmp); int nr = 0; for (int it : x) idx[++nr] = it; idx[++nr] = 1; for (int it : y) idx[++nr] = it; vector <int> ans; ans.pb (n); ans.pb (idx[1]); nr = 2; for (int i = 2; i <= n - 1; i++) { while (nr >= 2 && !is_clockwise (ans[nr - 2], ans.back (), idx[i])) { ans.pop_back (); nr--; } ans.pb (idx[i]); nr++; } while (ans.size () > 3) { if (!is_clockwise(ans.back (), ans.front (), ans[1])) ans.erase (ans.begin ()); else if (!is_clockwise(ans[ans.size () - 2], ans.back (), ans.front ())) ans.pop_back (); else { give_answer (ans.size ()); return 0; } } give_answer (ans.size ()); return 0; }

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

tri.cpp: In function 'bool cmp(int, int)':
tri.cpp:5:26: error: 'n' was not declared in this scope
     return is_clockwise (n, a, b);
                          ^
tri.cpp:5:12: error: 'is_clockwise' was not declared in this scope
     return is_clockwise (n, a, b);
            ^~~~~~~~~~~~
tri.cpp:5:12: note: suggested alternative: 'funlockfile'
     return is_clockwise (n, a, b);
            ^~~~~~~~~~~~
            funlockfile
tri.cpp: In function 'int main()':
tri.cpp:11:13: error: 'get_n' was not declared in this scope
     int n = get_n ();
             ^~~~~
tri.cpp:11:13: note: suggested alternative: 'getwc'
     int n = get_n ();
             ^~~~~
             getwc
tri.cpp:14:13: error: 'is_clockwise' was not declared in this scope
         if (is_clockwise (n, i, 1))
             ^~~~~~~~~~~~
tri.cpp:14:13: note: suggested alternative: 'funlockfile'
         if (is_clockwise (n, i, 1))
             ^~~~~~~~~~~~
             funlockfile
tri.cpp:36:28: error: 'is_clockwise' was not declared in this scope
         while (nr >= 2 && !is_clockwise (ans[nr - 2], ans.back (), idx[i])) {
                            ^~~~~~~~~~~~
tri.cpp:36:28: note: suggested alternative: 'funlockfile'
         while (nr >= 2 && !is_clockwise (ans[nr - 2], ans.back (), idx[i])) {
                            ^~~~~~~~~~~~
                            funlockfile
tri.cpp:46:14: error: 'is_clockwise' was not declared in this scope
         if (!is_clockwise(ans.back (), ans.front (), ans[1]))
              ^~~~~~~~~~~~
tri.cpp:46:14: note: suggested alternative: 'funlockfile'
         if (!is_clockwise(ans.back (), ans.front (), ans[1]))
              ^~~~~~~~~~~~
              funlockfile
tri.cpp:51:13: error: 'give_answer' was not declared in this scope
             give_answer (ans.size ());
             ^~~~~~~~~~~
tri.cpp:55:5: error: 'give_answer' was not declared in this scope
     give_answer (ans.size ());
     ^~~~~~~~~~~