Submission #711768

# Submission time Handle Problem Language Result Execution time Memory
711768 2023-03-17T13:03:02 Z william950615 Checker (COCI19_checker) C++14
110 / 110
181 ms 8140 KB
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define mkp make_pair
#define REP(i,n, ...) for( int i = (0), ##__VA_ARGS__; i < n; ++ i)
#define FOR(i,a,b,...) for (int i = (a), ##__VA_ARGS__; i <= (b); ++i)
#define RFOR(i,a,b,...) for (int i = (a), ##__VA_ARGS__; i >= (b); --i)

#define SZ(x) ((int)x.size())
#define MEM(x) memset(x, 0, sizeof(x))
#define ALL(x) begin(x), end(x)
#define iter(x,a) begin(x)+a, end(x)
#define DEBUG
#ifdef DEBUG
	template<typename T> void _DO(T&&x){cerr << x << '\n';}
	template<typename A, typename ...B> void _DO(A&&a, B&&...b){cerr<<a<<','; _DO(b...);}
	#define de(...) do{\
		fprintf(stderr, "%s-%d(%s):", __func__, __LINE__, #__VA_ARGS__);\
		_DO(__VA_ARGS__);\
	}while(0);
#else
	#define de(...)
#endif

template<typename T>
using V = vector<T>;
typedef long long ll;
typedef pair<int,int> pii;

constexpr int mxN = 2e5+1;

inline void solve() {
	int testcase = 0;
	cin >> testcase;
	int N; cin >> N;
	V< pair<int,int> > vc(N);
	REP(i,N) {
		char c;
		cin >> c;
		vc[ i ] = mkp( (i+1)%N, c-'0' );

	}
	V<array<int,4>> op(N-3);
	REP(i,N-3) {
		cin >> op[i][0] >> op[i][1] >> op[i][2];
		--op[i][0], --op[i][1];
		if( op[i][0] > op[i][1] ) swap( op[i][0], op[i][1]);
		op[i][3] = min( (op[i][0]-op[i][1]+N)%N, (op[i][1]-op[i][0]+N)%N );
	}



	sort( ALL(op), [&]( array<int,4>&a, array<int,4>&b) {
			return a[3] < b[3];
			});

	int ans = 2; 
	auto getPos = [&]( int cur ) {
		return cur == -1 ? mkp(-1,-1) : vc[ cur ];
	};
	/*
	for( auto &i : op ) {
		cout << i[0] << ' ' << i[1] << ' '  << i[2]  << ' ' << (i[0]-i[1]+N)%N << '\n';
	}
	de( ans );
	*/
	REP(i,N-3) {
		auto d = op[ i ];
		if( getPos( getPos( d[1] ).F ).F == d[0 ] ) swap( d[1], d[0] );
		const auto Cur = getPos( d[0] ); 
		const auto Nxt = getPos( Cur.F );
		if( Nxt.F == d[1]) {
			int v = d[2] + Cur.S + Nxt.S;
			if( v != 6 ) ans = 1;
			vc[ Cur.F ]	= mkp( -1, -1 );
			vc[ d[0] ] = mkp(Nxt.F, d[2]);;
		}
		else {
			ans = 0;
			break;
		}
	}
	cout << (ans == 0 ? "neispravna triangulacija":  ans == 1 ? "neispravno bojenje": "tocno")  <<'\n';
}
int main () {
	int T = 1;
#ifdef Local
	cin >> T;
#endif
	while(T--) solve();
}


# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 159 ms 4992 KB Output is correct
2 Correct 164 ms 8056 KB Output is correct
3 Correct 160 ms 8056 KB Output is correct
4 Correct 157 ms 8116 KB Output is correct
5 Correct 165 ms 8020 KB Output is correct
6 Correct 181 ms 7992 KB Output is correct
7 Correct 165 ms 8032 KB Output is correct
8 Correct 169 ms 7996 KB Output is correct
9 Correct 167 ms 8140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 159 ms 4992 KB Output is correct
2 Correct 173 ms 8136 KB Output is correct
3 Correct 160 ms 8044 KB Output is correct
4 Correct 175 ms 6928 KB Output is correct
5 Correct 165 ms 6972 KB Output is correct
6 Correct 170 ms 7060 KB Output is correct
7 Correct 170 ms 7052 KB Output is correct
8 Correct 172 ms 7108 KB Output is correct
9 Correct 169 ms 6984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 159 ms 4992 KB Output is correct
16 Correct 164 ms 8056 KB Output is correct
17 Correct 160 ms 8056 KB Output is correct
18 Correct 157 ms 8116 KB Output is correct
19 Correct 165 ms 8020 KB Output is correct
20 Correct 181 ms 7992 KB Output is correct
21 Correct 165 ms 8032 KB Output is correct
22 Correct 169 ms 7996 KB Output is correct
23 Correct 167 ms 8140 KB Output is correct
24 Correct 159 ms 4992 KB Output is correct
25 Correct 173 ms 8136 KB Output is correct
26 Correct 160 ms 8044 KB Output is correct
27 Correct 175 ms 6928 KB Output is correct
28 Correct 165 ms 6972 KB Output is correct
29 Correct 170 ms 7060 KB Output is correct
30 Correct 170 ms 7052 KB Output is correct
31 Correct 172 ms 7108 KB Output is correct
32 Correct 169 ms 6984 KB Output is correct
33 Correct 166 ms 6948 KB Output is correct
34 Correct 157 ms 6984 KB Output is correct
35 Correct 158 ms 7016 KB Output is correct
36 Correct 164 ms 7024 KB Output is correct
37 Correct 162 ms 6988 KB Output is correct
38 Correct 159 ms 6944 KB Output is correct
39 Correct 161 ms 6988 KB Output is correct
40 Correct 171 ms 7000 KB Output is correct
41 Correct 161 ms 6932 KB Output is correct
42 Correct 164 ms 7016 KB Output is correct
43 Correct 164 ms 7016 KB Output is correct