This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include"trilib.h"
using namespace std;
const int MAXN = 40010;
/*
int get_n()
{
int aux;
scanf("%d", &aux);
return aux;
}
bool is_clockwise(int a, int b, int c)
{
char aux;
printf("? %d %d %d\n", a, b, c);
scanf(" %c", &aux);
return (aux == 'y');
}
void give_answer(int s)
{
printf("%d\n", s);
}
*/
set<pair<int, int> > ch;
set<pair<int, int> > :: iterator it;
bool marc[MAXN], ans[MAXN];
int main ()
{
int n = get_n();
if(!is_clockwise(1, 2, 3)) ch.insert({2, 1}), ch.insert({3, 2}), ch.insert({1, 3});
else ch.insert({1, 2}), ch.insert({2, 3}), ch.insert({3, 1});
marc[1] = marc[2] = marc[3] = true;
while(!ch.empty())
{
int A = 0, B = 0, C = 0;
vector<pair<int, int> > true_border;
for(it = ch.begin(); it != ch.end(); it++)
{
int a = (*it).first;
int b = (*it).second;
for(int c = 1; c <= n; c++)
{
if(marc[c] || a == c || b == c || a == b) continue;
if(!is_clockwise(a, b, c))
{
marc[c] = true;
A = a, B = b, C = c;
break;
}
}
if(!A) true_border.push_back((*it)), ans[a] = ans[b] = true;
else break;
}
for(int i = 0; i < true_border.size(); i++) ch.erase(true_border[i]);
if(A) ch.insert({A, C}), ch.insert({C, B});
ch.erase({A, B});
}
int qtt = 0;
for(int i = 1; i <= n; i++) qtt += ans[i];
give_answer(qtt);
}
Compilation message (stderr)
tri.cpp: In function 'int main()':
tri.cpp:65:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
65 | for(int i = 0; i < true_border.size(); i++) ch.erase(true_border[i]);
| ~~^~~~~~~~~~~~~~~~~~~~
# | 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... |