제출 #972531

#제출 시각아이디문제언어결과실행 시간메모리
972531MilosMilutinovicTriangles (CEOI18_tri)C++14
75 / 100
2229 ms240924 KiB
#include <bits/stdc++.h> #include "trilib.h" using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n = get_n(); map<array<int, 3>, bool> mp; auto Ask = [&](int i, int j, int k) { if (mp.count({i, j, k})) { return mp[{i, j, k}]; } mp[{i, j, k}] = is_clockwise(i, j, k); mp[{k, j, i}] = !mp[{i, j, k}]; return mp[{i, j, k}]; }; vector<vector<int>> pts(2); for (int i = 3; i <= n; i++) { pts[!Ask(1, 2, i)].push_back(i); } pts[1].push_back(2); for (int it = 0; it < 2; it++) { sort(pts[it].begin(), pts[it].end(), [&](int i, int j) { if (i == j) { return false; } return !Ask(1, i, j); }); } vector<int> v; for (int i : pts[1]) { v.push_back(i); } v.push_back(1); for (int i : pts[0]) { v.push_back(i); } vector<int> res; int bef = 0; for (int it = 0; it < 2; it++) { bef = (int) res.size(); for (int i : v) { while (res.size() >= 2 && Ask(res.rbegin()[1], res.back(), i)) { res.pop_back(); } res.push_back(i); } } cout << (int) res.size() - bef << endl; return 0; }
#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...