이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <iostream>
#include "trilib.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int,int> tiii;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
int n, guesses = 999995;
map<tiii, bool> cw;
//
// bool is_clockwise(int a, int b, int c) {
// cout << "clockwise? " << a << " " << b << " " << c << endl;
// bool ans;
// cin >> ans;
// return ans;
// }
//
// int get_n(){
// int N; cin >> N; return N;
// }
bool clockwise(int a, int b, int c){
tiii t = make_tuple(a, b, c);
if (cw.find(t) != cw.end()) return cw[t];
guesses--;
bool ans = is_clockwise(a, b, c);
cw[{a, b, c}] = cw[{b, c, a}] = cw[{c, a, b}] = ans;
cw[{a, c, b}] = cw[{c, b, a}] = cw[{b, a, c}] = !ans;
return ans;
}
vi sort_hull() {
int sortby = 1;
vi s = {2};
rep(i, 3, n + 1) {
int low = 0, high = s.size(), mid;
while (high - low > 1) {
mid = (high + low) / 2;
if (clockwise(sortby, i, s[mid])) high = mid;
else low = mid;
}
if (clockwise(sortby, i, s[low])) s.insert(s.begin() + low, i);
else s.insert(s.begin() + low + 1, i);
}
s.insert(s.begin(), sortby);
return s;
}
int main()
{
n = get_n();
int sortby = 1;
vi s = sort_hull();
int ans = n;
vi nxt(n+1);
rep(i,0,n-1) nxt[s[i]] = s[i + 1];
nxt[s[n - 1]] = s[0];
int cur = 1;
bool lastupd = 1;
while (true) {
if (!clockwise(cur, nxt[cur], nxt[nxt[cur]])) {
ans--;
nxt[cur] = nxt[nxt[cur]];
lastupd = cur;
}
cur = nxt[cur];
if (lastupd == cur) break;
}
cout << ans << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
tri.cpp: In function 'int main()':
tri.cpp:62:7: warning: unused variable 'sortby' [-Wunused-variable]
62 | int sortby = 1;
| ^~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |