Submission #267114

#TimeUsernameProblemLanguageResultExecution timeMemory
267114Kenzo_1114Triangles (CEOI18_tri)C++17
0 / 100
1 ms384 KiB
#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();

	bool type = is_clockwise(1, 2, 3);
	if(!type)	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)	continue;

				type = is_clockwise(a, b, c);
				if(!type)
				{
					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]);

		ch.erase({A, B});
		if(A)	ch.insert({A, C}), ch.insert({C, 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:67: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]
   67 |   for(int i = 0; i < true_border.size(); i++) ch.erase(true_border[i]);
      |                  ~~^~~~~~~~~~~~~~~~~~~~
#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...