답안 #229224

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
229224 2020-05-03T21:13:21 Z VEGAnn Checker (COCI19_checker) C++14
110 / 110
277 ms 43140 KB
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define MP make_pair
#define MP3(a, b, c) MP(MP(a, b), c)
#define PB push_back
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define piis pair<pii, string>
#define ft first
#define sd second
using namespace std;
const int N = 200100;
unordered_map<int, int> rib[N];
string s;
int x[N], y[N], z[N], n, fen[N], nm[N], len[N], nt[N], pr[N], sta[N], ed[N];

void update(int ps, int vl){
	for (; ps < N; ps = (ps | (ps + 1)))
		fen[ps] += vl;
}

int sum(int ps){
	int res = 0;
	
	for (; ps >= 0; ps = (ps & (ps + 1)) - 1)
		res += fen[ps];
	
	return res;
}

bool cmp1(int _x, int _y){
	return (y[_x] - x[_x]) < (y[_y] - x[_y]);
}

bool cmp(int _x, int _y){
	return len[_x] < len[_y];
}

int MEX(int x, int y){
	return 3 - (x + y);
}

int main(){
	
	ios_base::sync_with_stdio(0); cin.tie(0);
	
//	freopen("in.txt","r",stdin); 
	
	cin >> n >> n;
	
	cin >> s;
	
	for (int i = 0; i < n - 3; i++){
		cin >> x[i] >> y[i] >> z[i];
		x[i]--; y[i]--; z[i]--;
		
		if (x[i] > y[i]) swap(x[i], y[i]);
		
		len[i] = min(y[i] - x[i], n - (y[i] - x[i]));
		
		nm[i] = i;
	}
	
	sort(nm, nm + n - 3, cmp1);
	
	for (int it = 0; it < n - 3; it++) {
			
		int i = nm[it];
						
		if (sum(y[i]) - sum(x[i] - 1) - sta[y[i]] + ed[x[i]] != 0){
			cout << "neispravna triangulacija";
			return 0;
		}
		
		update(x[i], 1);
		update(y[i], -1);
		
		sta[x[i]]++;
		ed[y[i]]++;
	}
		
	sort(nm, nm + n - 3, cmp);
	
	for (int i = 0; i < n; i++){
		nt[i] = (i + 1) % n;
		pr[i] = (i - 1 + n) % n;
		
		rib[i][nt[i]] = (s[i] - '1');
	}
	
	
	for (int it = 0; it < n - 3; it++){
		int i = nm[it];
				
		int pro = nt[x[i]];
		
		if (nt[pro] != y[i]){
			swap(x[i], y[i]);
			
			pro = nt[x[i]];
		}
		
		if (MEX(rib[x[i]][pro], rib[pro][y[i]]) != z[i]){
			cout << "neispravno bojenje";
			return 0;
		}
		
		nt[x[i]] = y[i];
		pr[y[i]] = x[i];
	
		rib[x[i]][y[i]] = z[i];
	}
	
	cout << "tocno";
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 11392 KB Output is correct
2 Correct 11 ms 11392 KB Output is correct
3 Correct 11 ms 11392 KB Output is correct
4 Correct 11 ms 11392 KB Output is correct
5 Correct 12 ms 11392 KB Output is correct
6 Correct 11 ms 11392 KB Output is correct
7 Correct 11 ms 11392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 11392 KB Output is correct
2 Correct 11 ms 11392 KB Output is correct
3 Correct 11 ms 11392 KB Output is correct
4 Correct 11 ms 11392 KB Output is correct
5 Correct 12 ms 11392 KB Output is correct
6 Correct 11 ms 11392 KB Output is correct
7 Correct 11 ms 11392 KB Output is correct
8 Correct 12 ms 11648 KB Output is correct
9 Correct 13 ms 11648 KB Output is correct
10 Correct 12 ms 11520 KB Output is correct
11 Correct 12 ms 11520 KB Output is correct
12 Correct 12 ms 11648 KB Output is correct
13 Correct 13 ms 11648 KB Output is correct
14 Correct 13 ms 11648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 274 ms 43012 KB Output is correct
2 Correct 263 ms 43140 KB Output is correct
3 Correct 102 ms 20996 KB Output is correct
4 Correct 102 ms 20996 KB Output is correct
5 Correct 104 ms 20996 KB Output is correct
6 Correct 199 ms 40572 KB Output is correct
7 Correct 197 ms 42148 KB Output is correct
8 Correct 102 ms 19076 KB Output is correct
9 Correct 108 ms 19076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 273 ms 43108 KB Output is correct
2 Correct 267 ms 43012 KB Output is correct
3 Correct 176 ms 35996 KB Output is correct
4 Correct 156 ms 35076 KB Output is correct
5 Correct 168 ms 35096 KB Output is correct
6 Correct 202 ms 40452 KB Output is correct
7 Correct 211 ms 42340 KB Output is correct
8 Correct 163 ms 34180 KB Output is correct
9 Correct 165 ms 34344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 11392 KB Output is correct
2 Correct 11 ms 11392 KB Output is correct
3 Correct 11 ms 11392 KB Output is correct
4 Correct 11 ms 11392 KB Output is correct
5 Correct 12 ms 11392 KB Output is correct
6 Correct 11 ms 11392 KB Output is correct
7 Correct 11 ms 11392 KB Output is correct
8 Correct 12 ms 11648 KB Output is correct
9 Correct 13 ms 11648 KB Output is correct
10 Correct 12 ms 11520 KB Output is correct
11 Correct 12 ms 11520 KB Output is correct
12 Correct 12 ms 11648 KB Output is correct
13 Correct 13 ms 11648 KB Output is correct
14 Correct 13 ms 11648 KB Output is correct
15 Correct 274 ms 43012 KB Output is correct
16 Correct 263 ms 43140 KB Output is correct
17 Correct 102 ms 20996 KB Output is correct
18 Correct 102 ms 20996 KB Output is correct
19 Correct 104 ms 20996 KB Output is correct
20 Correct 199 ms 40572 KB Output is correct
21 Correct 197 ms 42148 KB Output is correct
22 Correct 102 ms 19076 KB Output is correct
23 Correct 108 ms 19076 KB Output is correct
24 Correct 273 ms 43108 KB Output is correct
25 Correct 267 ms 43012 KB Output is correct
26 Correct 176 ms 35996 KB Output is correct
27 Correct 156 ms 35076 KB Output is correct
28 Correct 168 ms 35096 KB Output is correct
29 Correct 202 ms 40452 KB Output is correct
30 Correct 211 ms 42340 KB Output is correct
31 Correct 163 ms 34180 KB Output is correct
32 Correct 165 ms 34344 KB Output is correct
33 Correct 277 ms 42988 KB Output is correct
34 Correct 268 ms 43012 KB Output is correct
35 Correct 102 ms 20996 KB Output is correct
36 Correct 99 ms 20996 KB Output is correct
37 Correct 166 ms 35076 KB Output is correct
38 Correct 178 ms 36608 KB Output is correct
39 Correct 162 ms 34948 KB Output is correct
40 Correct 185 ms 40452 KB Output is correct
41 Correct 208 ms 42280 KB Output is correct
42 Correct 109 ms 19460 KB Output is correct
43 Correct 164 ms 34180 KB Output is correct