Submission #466862

#TimeUsernameProblemLanguageResultExecution timeMemory
466862idk321Triangles (CEOI18_tri)C++17
Compilation error
0 ms0 KiB
#include "trilib.h" using namespace std; typedef long long ll; const int N = 501; vector<int> adj[N]; bool vis[N]; bool st[N]; int n; bool cycle(int node) { if (st[node]) return true; if (vis[node]) return false; vis[node] = true; st[node] = true; for (int next : adj[node]) { if (cycle(next)) return true; } st[node] = false; return false; } bool isGood(int node) { for (int i = 0; i < N; i++) { st[i] = false; vis[i] = false; adj[i].clear(); } for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i == node || j == node) continue; if (is_clockwise(node, i, j)) { adj[j].push_back(i); } else adj[i].push_back(j); } } bool good = true; for (int i = 1; i <= n; i++) { if (cycle(i)) good = false; } return good; } int getRes(int node) { int first = -1; for (int i = 1; i <= n; i++) { if (i == node) continue; bool good = true; for (int j = i + 1; j <= n; j++) { if (i == node || j == node) continue; if (!is_clockwise(node, i, j)) { good = false; break; } } if (good) { first = i; break; } } int cur = first; int prev = node; int res = 1; while (cur != node) { int next = -1; for (int i = 1; i <= n; i++) { if (i == prev) continue; if (i == cur) continue; if (next == -1) next = i; else { if (is_clockwise(cur, i, next)) { next = i; } } } prev = cur; cur = next; res++; } return res; } int main() { n = get_n(); for (int i = 1; i <= n; i++) { if (isGood(i)) { int res = getRes(i); give_answer(res); break; } } } /* 6 1 1 4 3 2 2 1 4 5 1 3 2 */

Compilation message (stderr)

tri.cpp:6:1: error: 'vector' does not name a type
    6 | vector<int> adj[N];
      | ^~~~~~
tri.cpp: In function 'bool cycle(int)':
tri.cpp:15:21: error: 'adj' was not declared in this scope
   15 |     for (int next : adj[node]) {
      |                     ^~~
tri.cpp: In function 'bool isGood(int)':
tri.cpp:26:9: error: 'adj' was not declared in this scope
   26 |         adj[i].clear();
      |         ^~~
tri.cpp:32:17: error: 'adj' was not declared in this scope
   32 |                 adj[j].push_back(i);
      |                 ^~~
tri.cpp:33:20: error: 'adj' was not declared in this scope
   33 |             } else adj[i].push_back(j);
      |                    ^~~