제출 #116726

#제출 시각아이디문제언어결과실행 시간메모리
116726johuthaTriangles (CEOI18_tri)C++14
0 / 100
2 ms384 KiB
#include "trilib.h" #include <vector> #include <algorithm> #include <iostream> #define int int64_t using namespace std; signed main() { int n = get_n(); vector<int> next(n, -1); if (is_clockwise(1, 2, 3)) { next[0] = 1; next[1] = 2; next[2] = 0; } else { next[0] = 2; next[1] = 0; next[2] = 1; } int start = 0; for (int i = 3; i < n; i++) { int curr = -1; bool firstconc = false; bool sec = false; while (curr != start && sec) { if (curr == start) sec = true; if (curr == -1) { curr = start; } bool cl = is_clockwise(curr + 1, i + 1, next[curr] + 1); if (cl) { if (!firstconc) continue; next[i] = next[curr]; next[curr] = i; while (true) { if (is_clockwise(i + 1, next[i] + 1, next[next[i]] + 1)) break; else { int old = next[i]; next[i] = next[next[i]]; next[old] = -1; if (old == start) start = i; } } break; } else { firstconc = true; curr = next[curr]; } } } /*int curr = -1; while (curr != start) { if (curr == -1) curr = start; cout << curr << " "; curr = next[curr]; }*/ int res = 0; for (int i : next) { if (i != -1) res++; } give_answer(res); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...