Submission #292314

# Submission time Handle Problem Language Result Execution time Memory
292314 2020-09-06T20:11:40 Z kingfran1907 Checker (COCI19_checker) C++14
110 / 110
238 ms 10848 KB
#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef long long llint;

const int maxn = 2e5+10;
const int base = 31337;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 20;
const int off = 1 << logo;
const int treesiz = off << 1;

int t;
int n;
int c[maxn];
vector< pair< pair<int, int>, int > > v;
bool bio[maxn];
int nx[maxn];

bool cmp(pair< pair<int, int>, int> a, pair< pair<int, int>, int> b) {
	return ((a.X.Y - a.X.X + n) % n) < ((b.X.Y - b.X.X + n) % n); 
}

int main() {
	scanf("%d%d", &t, &n);
	memset(bio, false, sizeof bio);
	for (int i = 0; i < n; i++) {
		char x;
		scanf(" %c", &x);
		c[i] = x - '1';
		nx[i] = (i + 1) % n; 
	}

	for (int i = 3; i < n; i++) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c); a--, b--, c--;
		v.push_back(make_pair(make_pair(a, b), c));
		v.push_back(make_pair(make_pair(b, a), c));
	}
	sort(v.begin(), v.end(), cmp);

	bool flag1 = true;
	bool flag2 = true;
	for (int i = 0; i < n - 3; i++) {
		int x = v[i].X.X;
		int y = v[i].X.Y;
		int cl = v[i].Y;

		//printf("debug: %d %d -> %d %d %d\n", x + 1, y + 1, c[x], c[nx[x]], cl);

		if (bio[x] || bio[y]) {
			flag1 = false;
			break;
		}
		if (nx[nx[x]] != y) {
			flag1 = false;
			break;
		}
		bio[nx[x]] = true;
		if (!(c[x] + c[nx[x]] + cl == 3 && min({c[x], c[nx[x]], cl}) == 0)) flag2 = false;
		c[x] = cl;
		nx[x] = y;
	}

	if (!flag1) printf("neispravna triangulacija\n");
	else if (!flag2) printf("neispravno bojenje\n");
	else printf("tocno\n");
	return 0;
}

Compilation message

checker.cpp: In function 'int main()':
checker.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   28 |  scanf("%d%d", &t, &n);
      |  ~~~~~^~~~~~~~~~~~~~~~
checker.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   32 |   scanf(" %c", &x);
      |   ~~~~~^~~~~~~~~~~
checker.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   39 |   scanf("%d%d%d", &a, &b, &c); a--, b--, c--;
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 2 ms 640 KB Output is correct
9 Correct 2 ms 640 KB Output is correct
10 Correct 2 ms 640 KB Output is correct
11 Correct 2 ms 640 KB Output is correct
12 Correct 2 ms 640 KB Output is correct
13 Correct 2 ms 640 KB Output is correct
14 Correct 2 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 194 ms 10724 KB Output is correct
2 Correct 196 ms 10624 KB Output is correct
3 Correct 194 ms 10724 KB Output is correct
4 Correct 193 ms 10720 KB Output is correct
5 Correct 191 ms 10728 KB Output is correct
6 Correct 232 ms 10728 KB Output is correct
7 Correct 229 ms 10724 KB Output is correct
8 Correct 231 ms 10720 KB Output is correct
9 Correct 233 ms 10724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 194 ms 10728 KB Output is correct
2 Correct 193 ms 10720 KB Output is correct
3 Correct 195 ms 10724 KB Output is correct
4 Correct 194 ms 10724 KB Output is correct
5 Correct 195 ms 10720 KB Output is correct
6 Correct 234 ms 10724 KB Output is correct
7 Correct 231 ms 10720 KB Output is correct
8 Correct 234 ms 10728 KB Output is correct
9 Correct 238 ms 10728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 2 ms 640 KB Output is correct
9 Correct 2 ms 640 KB Output is correct
10 Correct 2 ms 640 KB Output is correct
11 Correct 2 ms 640 KB Output is correct
12 Correct 2 ms 640 KB Output is correct
13 Correct 2 ms 640 KB Output is correct
14 Correct 2 ms 640 KB Output is correct
15 Correct 194 ms 10724 KB Output is correct
16 Correct 196 ms 10624 KB Output is correct
17 Correct 194 ms 10724 KB Output is correct
18 Correct 193 ms 10720 KB Output is correct
19 Correct 191 ms 10728 KB Output is correct
20 Correct 232 ms 10728 KB Output is correct
21 Correct 229 ms 10724 KB Output is correct
22 Correct 231 ms 10720 KB Output is correct
23 Correct 233 ms 10724 KB Output is correct
24 Correct 194 ms 10728 KB Output is correct
25 Correct 193 ms 10720 KB Output is correct
26 Correct 195 ms 10724 KB Output is correct
27 Correct 194 ms 10724 KB Output is correct
28 Correct 195 ms 10720 KB Output is correct
29 Correct 234 ms 10724 KB Output is correct
30 Correct 231 ms 10720 KB Output is correct
31 Correct 234 ms 10728 KB Output is correct
32 Correct 238 ms 10728 KB Output is correct
33 Correct 195 ms 10720 KB Output is correct
34 Correct 203 ms 10848 KB Output is correct
35 Correct 200 ms 10724 KB Output is correct
36 Correct 192 ms 10728 KB Output is correct
37 Correct 194 ms 10724 KB Output is correct
38 Correct 195 ms 10724 KB Output is correct
39 Correct 196 ms 10724 KB Output is correct
40 Correct 233 ms 10740 KB Output is correct
41 Correct 237 ms 10720 KB Output is correct
42 Correct 228 ms 10720 KB Output is correct
43 Correct 230 ms 10724 KB Output is correct