Submission #464592

# Submission time Handle Problem Language Result Execution time Memory
464592 2021-08-13T13:36:24 Z Jasiekstrz Checker (COCI19_checker) C++17
110 / 110
114 ms 14924 KB
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=2e5;
const string OK="tocno\n",WRONGCOL="neispravno bojenje\n",WRONGTRI="neispravna triangulacija\n";
int tab[N+10];
vector<pair<int,int>> e[N+10];
vector<int> st;
bool patriotic(int a,int b,int c)
{
	return (a!=b && a!=c && b!=c);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int sub,n;
	cin>>sub>>n;
	for(int i=1;i<=n;i++)
	{
		char c;
		cin>>c;
		tab[i]=c-'1';
	}
	for(int i=1;i<=n-3;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		c--;
		if(a>b)
			swap(a,b);
		e[b].emplace_back(a,c);
	}
	for(int i=1;i<=n;i++)
	{
		sort(e[i].begin(),e[i].end());
		reverse(e[i].begin(),e[i].end());
	}
	for(int i=1;i<=n;i++)
	{
		for(auto [a,c]:e[i])
		{
			if(st.size()<2 || st[st.size()-2]!=a)
			{
				cout<<WRONGTRI;
				return 0;
			}
			if(!patriotic(c,tab[st[st.size()-2]],tab[st.back()]))
			{
				cout<<WRONGCOL;
				return 0;
			}
			st.pop_back();
			tab[st.back()]=c;
		}
		st.push_back(i);
	}
	if(st.size()!=3)
		cout<<WRONGTRI;
	else if(!patriotic(tab[st[0]],tab[st[1]],tab[st[2]]))
		cout<<WRONGCOL;
	else
		cout<<OK;
	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
8 Correct 4 ms 5068 KB Output is correct
9 Correct 4 ms 5068 KB Output is correct
10 Correct 4 ms 5068 KB Output is correct
11 Correct 4 ms 5028 KB Output is correct
12 Correct 4 ms 5068 KB Output is correct
13 Correct 4 ms 5068 KB Output is correct
14 Correct 4 ms 5068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 105 ms 12684 KB Output is correct
2 Correct 106 ms 12596 KB Output is correct
3 Correct 100 ms 12548 KB Output is correct
4 Correct 97 ms 12564 KB Output is correct
5 Correct 97 ms 12568 KB Output is correct
6 Correct 93 ms 11384 KB Output is correct
7 Correct 106 ms 14836 KB Output is correct
8 Correct 95 ms 12692 KB Output is correct
9 Correct 93 ms 14348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 114 ms 12600 KB Output is correct
2 Correct 108 ms 12692 KB Output is correct
3 Correct 100 ms 12528 KB Output is correct
4 Correct 96 ms 12520 KB Output is correct
5 Correct 96 ms 12620 KB Output is correct
6 Correct 91 ms 13064 KB Output is correct
7 Correct 108 ms 14364 KB Output is correct
8 Correct 86 ms 11712 KB Output is correct
9 Correct 95 ms 14924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
8 Correct 4 ms 5068 KB Output is correct
9 Correct 4 ms 5068 KB Output is correct
10 Correct 4 ms 5068 KB Output is correct
11 Correct 4 ms 5028 KB Output is correct
12 Correct 4 ms 5068 KB Output is correct
13 Correct 4 ms 5068 KB Output is correct
14 Correct 4 ms 5068 KB Output is correct
15 Correct 105 ms 12684 KB Output is correct
16 Correct 106 ms 12596 KB Output is correct
17 Correct 100 ms 12548 KB Output is correct
18 Correct 97 ms 12564 KB Output is correct
19 Correct 97 ms 12568 KB Output is correct
20 Correct 93 ms 11384 KB Output is correct
21 Correct 106 ms 14836 KB Output is correct
22 Correct 95 ms 12692 KB Output is correct
23 Correct 93 ms 14348 KB Output is correct
24 Correct 114 ms 12600 KB Output is correct
25 Correct 108 ms 12692 KB Output is correct
26 Correct 100 ms 12528 KB Output is correct
27 Correct 96 ms 12520 KB Output is correct
28 Correct 96 ms 12620 KB Output is correct
29 Correct 91 ms 13064 KB Output is correct
30 Correct 108 ms 14364 KB Output is correct
31 Correct 86 ms 11712 KB Output is correct
32 Correct 95 ms 14924 KB Output is correct
33 Correct 99 ms 12572 KB Output is correct
34 Correct 97 ms 12516 KB Output is correct
35 Correct 104 ms 12640 KB Output is correct
36 Correct 96 ms 12604 KB Output is correct
37 Correct 107 ms 12612 KB Output is correct
38 Correct 99 ms 12612 KB Output is correct
39 Correct 98 ms 12560 KB Output is correct
40 Correct 87 ms 11612 KB Output is correct
41 Correct 98 ms 14184 KB Output is correct
42 Correct 107 ms 12668 KB Output is correct
43 Correct 103 ms 11792 KB Output is correct