Submission #222406

# Submission time Handle Problem Language Result Execution time Memory
222406 2020-04-13T06:40:56 Z oolimry Checker (COCI19_checker) C++14
110 / 110
969 ms 64856 KB
#include <bits/stdc++.h>

using namespace std;
typedef pair<int,int> ii;
struct bracket{
	int pos; int other; bool open; int colour;
};
bool comp(bracket a, bracket b){
	if(a.pos != b.pos) return a.pos < b.pos;
	
	if(a.open && !b.open) return false;
	if(!a.open && b.open) return true;
	
	if(a.open){
		return a.other > b.other;
	}
	else{
		return a.other > b.other;
	}
}

void notTriangle(){
	cout << "neispravna triangulacija";
	exit(0);
}

map<ii, int> Colour;

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	int ST; cin >> ST;
	
	int n; cin >> n;
	string S; cin >> S;
	
	vector<bracket> B;
	
	for(int i = 0;i < n;i++){
		int l = i+1;
		int r = i+2;
		if(r == n+1) r = 1;
		if(l > r) swap(l,r);
		int c = S[i] - '0';
		
		B.push_back({l,r,true,c});
		B.push_back({r,l,false,c});
		Colour[ii(l,r)] = c;
		Colour[ii(r,l)] = c;
	}
	
	for(int i = 0;i < n-3;i++){
		int l, r, c; cin >> l >> r >> c;
		if(l > r) swap(l,r);
		Colour[ii(l,r)] = c;
		Colour[ii(r,l)] = c;
		B.push_back({l,r,true,c});
		B.push_back({r,l,false,c});
	}
	
	sort(B.begin(),B.end(),comp);
	
	bool xxxxxxxxxxxxxxxxxxxxxxx = false;
	bracket pre = {0,0,0,0};
	stack<ii> s;
	for(bracket b : B){		
		//cout << b.pos << " " << b.other << " " << b.open << " " << b.colour << endl;
		
		if(b.open){
			s.push(ii(b.pos,b.other));
			
			if(pre.open){
				int x = b.pos;
				int y = pre.other;
				int z = b.other;
				
				set<int> CCC;
				CCC.insert(Colour[ii(x,y)]);
				CCC.insert(Colour[ii(x,z)]);
				CCC.insert(Colour[ii(z,y)]);
				
				//cout << x << " " << y << " " << z << "\n";
				
				if(CCC.size() != 3) xxxxxxxxxxxxxxxxxxxxxxx = true;
			}
		}
		else{
			ii t = s.top();
			if(t.first != b.other && t.second != b.pos){
				notTriangle();
			}
			else s.pop();
		}
		
		pre = b;
		
	}
	
	
	
	
	if(xxxxxxxxxxxxxxxxxxxxxxx) cout << "neispravno bojenje";
	else cout << "tocno";
	
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 8 ms 1024 KB Output is correct
9 Correct 8 ms 1024 KB Output is correct
10 Correct 8 ms 1024 KB Output is correct
11 Correct 8 ms 1024 KB Output is correct
12 Correct 10 ms 1024 KB Output is correct
13 Correct 9 ms 1024 KB Output is correct
14 Correct 8 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 911 ms 63372 KB Output is correct
2 Correct 896 ms 63200 KB Output is correct
3 Correct 747 ms 63308 KB Output is correct
4 Correct 753 ms 63180 KB Output is correct
5 Correct 724 ms 63180 KB Output is correct
6 Correct 948 ms 64216 KB Output is correct
7 Correct 928 ms 64184 KB Output is correct
8 Correct 784 ms 63356 KB Output is correct
9 Correct 806 ms 63580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 892 ms 63312 KB Output is correct
2 Correct 888 ms 63312 KB Output is correct
3 Correct 884 ms 63324 KB Output is correct
4 Correct 895 ms 63324 KB Output is correct
5 Correct 892 ms 63324 KB Output is correct
6 Correct 908 ms 64560 KB Output is correct
7 Correct 916 ms 64492 KB Output is correct
8 Correct 930 ms 64220 KB Output is correct
9 Correct 930 ms 64152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 8 ms 1024 KB Output is correct
9 Correct 8 ms 1024 KB Output is correct
10 Correct 8 ms 1024 KB Output is correct
11 Correct 8 ms 1024 KB Output is correct
12 Correct 10 ms 1024 KB Output is correct
13 Correct 9 ms 1024 KB Output is correct
14 Correct 8 ms 1024 KB Output is correct
15 Correct 911 ms 63372 KB Output is correct
16 Correct 896 ms 63200 KB Output is correct
17 Correct 747 ms 63308 KB Output is correct
18 Correct 753 ms 63180 KB Output is correct
19 Correct 724 ms 63180 KB Output is correct
20 Correct 948 ms 64216 KB Output is correct
21 Correct 928 ms 64184 KB Output is correct
22 Correct 784 ms 63356 KB Output is correct
23 Correct 806 ms 63580 KB Output is correct
24 Correct 892 ms 63312 KB Output is correct
25 Correct 888 ms 63312 KB Output is correct
26 Correct 884 ms 63324 KB Output is correct
27 Correct 895 ms 63324 KB Output is correct
28 Correct 892 ms 63324 KB Output is correct
29 Correct 908 ms 64560 KB Output is correct
30 Correct 916 ms 64492 KB Output is correct
31 Correct 930 ms 64220 KB Output is correct
32 Correct 930 ms 64152 KB Output is correct
33 Correct 888 ms 63180 KB Output is correct
34 Correct 888 ms 63180 KB Output is correct
35 Correct 771 ms 63212 KB Output is correct
36 Correct 725 ms 63180 KB Output is correct
37 Correct 891 ms 63316 KB Output is correct
38 Correct 895 ms 63320 KB Output is correct
39 Correct 894 ms 63308 KB Output is correct
40 Correct 919 ms 64212 KB Output is correct
41 Correct 929 ms 64856 KB Output is correct
42 Correct 820 ms 63704 KB Output is correct
43 Correct 969 ms 64212 KB Output is correct