# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
222395 |
2020-04-13T06:27:25 Z |
lyc |
Checker (COCI19_checker) |
C++14 |
|
702 ms |
36196 KB |
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x).size()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)
const int MX_N = 2e5+5;
using ii = pair<int,int>;
int ST;
int N;
int deg[MX_N];
set<ii> hull;
map<ii,int> edges;
queue<set<ii>::iterator> q;
bool check(set<ii>::iterator it) {
if (deg[it->first] != 2) return false;
//cout << "CHECKING " << it->first << " " << it->second << endl;
auto prv = (it == hull.begin() ? prev(hull.end()) : prev(it));
auto nxt = (next(it) == hull.end() ? hull.begin() : next(it));
ii e = ii(prv->first, nxt->first);
//cout << "\t edge " << e.first << " " << e.second << endl;
if (e.first > e.second) swap(e.first, e.second);
//cout << "\t good? " << edges.count(e) << endl;
return edges.count(e);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> ST;
cin >> N;
FOR(i,1,N){
char C; cin >> C;
edges[ii(i,i+1)] = C;
hull.insert(ii(i,C-'0'));
deg[i] = 2;
}
FOR(i,1,N-3){
int X, Y, C; cin >> X >> Y >> C;
if (X > Y) swap(X,Y);
edges[ii(X,Y)] = C;
++deg[X];
++deg[Y];
}
//set<ii>::iterator P = hull.end();
for (auto it = hull.begin(); it != hull.end(); ++it) {
//cout << "TRY " << it->first << " " << it->second << endl;
if (check(it)) {
//P = it;
q.push(it);
}
}
bool isPat = true;
while (!q.empty() && SZ(hull) > 2) {
auto P = q.front(); q.pop();
auto prv = (P == hull.begin() ? prev(hull.end()) : prev(P));
auto nxt = (next(P) == hull.end() ? hull.begin() : next(P));
ii e = ii(prv->first, nxt->first);
if (e.first > e.second) swap(e.first, e.second);
//cout << "HULL IS NOW " << SZ(hull) << " :: P " << P->first << " " << P->second << " :: E " << e.first << " " << e.second << endl;
int a = prv->second, b = P->second, c = edges[e];
isPat &= (a != b && a != c && b != c);
hull.erase(P);
--deg[e.first];
--deg[e.second];
ii nw = ii(prv->first, c);
hull.erase(prv);
hull.insert(nw);
//for (auto& x : hull) cout << x.first << " " << x.second << " || ";
//cout << endl;
if (check(nxt)) q.push(nxt);
if (check(prev(nxt))) q.push(prev(nxt));
}
if (SZ(hull) != 2) {
cout << "neispravna triangulacija" << '\n';
} else if (!isPat) {
cout << "neispravno bojenje" << '\n';
} else {
cout << "tocno" << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 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 |
5 ms |
384 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 |
10 ms |
768 KB |
Output is correct |
9 |
Correct |
7 ms |
768 KB |
Output is correct |
10 |
Correct |
9 ms |
640 KB |
Output is correct |
11 |
Correct |
6 ms |
640 KB |
Output is correct |
12 |
Correct |
8 ms |
768 KB |
Output is correct |
13 |
Correct |
7 ms |
640 KB |
Output is correct |
14 |
Correct |
7 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
702 ms |
35964 KB |
Output is correct |
2 |
Correct |
674 ms |
35968 KB |
Output is correct |
3 |
Correct |
698 ms |
35960 KB |
Output is correct |
4 |
Correct |
640 ms |
35960 KB |
Output is correct |
5 |
Correct |
630 ms |
36076 KB |
Output is correct |
6 |
Correct |
500 ms |
35576 KB |
Output is correct |
7 |
Correct |
464 ms |
35576 KB |
Output is correct |
8 |
Correct |
433 ms |
35512 KB |
Output is correct |
9 |
Correct |
361 ms |
35576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
670 ms |
36088 KB |
Output is correct |
2 |
Correct |
650 ms |
36064 KB |
Output is correct |
3 |
Correct |
646 ms |
36088 KB |
Output is correct |
4 |
Correct |
649 ms |
35960 KB |
Output is correct |
5 |
Correct |
674 ms |
35960 KB |
Output is correct |
6 |
Correct |
447 ms |
35576 KB |
Output is correct |
7 |
Correct |
473 ms |
35644 KB |
Output is correct |
8 |
Correct |
469 ms |
35576 KB |
Output is correct |
9 |
Correct |
464 ms |
35576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 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 |
10 ms |
768 KB |
Output is correct |
9 |
Correct |
7 ms |
768 KB |
Output is correct |
10 |
Correct |
9 ms |
640 KB |
Output is correct |
11 |
Correct |
6 ms |
640 KB |
Output is correct |
12 |
Correct |
8 ms |
768 KB |
Output is correct |
13 |
Correct |
7 ms |
640 KB |
Output is correct |
14 |
Correct |
7 ms |
768 KB |
Output is correct |
15 |
Correct |
702 ms |
35964 KB |
Output is correct |
16 |
Correct |
674 ms |
35968 KB |
Output is correct |
17 |
Correct |
698 ms |
35960 KB |
Output is correct |
18 |
Correct |
640 ms |
35960 KB |
Output is correct |
19 |
Correct |
630 ms |
36076 KB |
Output is correct |
20 |
Correct |
500 ms |
35576 KB |
Output is correct |
21 |
Correct |
464 ms |
35576 KB |
Output is correct |
22 |
Correct |
433 ms |
35512 KB |
Output is correct |
23 |
Correct |
361 ms |
35576 KB |
Output is correct |
24 |
Correct |
670 ms |
36088 KB |
Output is correct |
25 |
Correct |
650 ms |
36064 KB |
Output is correct |
26 |
Correct |
646 ms |
36088 KB |
Output is correct |
27 |
Correct |
649 ms |
35960 KB |
Output is correct |
28 |
Correct |
674 ms |
35960 KB |
Output is correct |
29 |
Correct |
447 ms |
35576 KB |
Output is correct |
30 |
Correct |
473 ms |
35644 KB |
Output is correct |
31 |
Correct |
469 ms |
35576 KB |
Output is correct |
32 |
Correct |
464 ms |
35576 KB |
Output is correct |
33 |
Correct |
674 ms |
36196 KB |
Output is correct |
34 |
Correct |
661 ms |
35960 KB |
Output is correct |
35 |
Correct |
682 ms |
36196 KB |
Output is correct |
36 |
Correct |
624 ms |
35960 KB |
Output is correct |
37 |
Correct |
683 ms |
35960 KB |
Output is correct |
38 |
Correct |
648 ms |
36088 KB |
Output is correct |
39 |
Correct |
645 ms |
36124 KB |
Output is correct |
40 |
Correct |
463 ms |
35552 KB |
Output is correct |
41 |
Correct |
494 ms |
35704 KB |
Output is correct |
42 |
Correct |
406 ms |
35544 KB |
Output is correct |
43 |
Correct |
465 ms |
35576 KB |
Output is correct |