Submission #712020

# Submission time Handle Problem Language Result Execution time Memory
712020 2023-03-18T00:41:24 Z pcc Checker (COCI19_checker) C++14
110 / 110
390 ms 55344 KB
#include <bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define fs first
#define sc second
struct node{
    set<pii> st;
    int pre,nxt;
    bool del;
    node(){
        pre = nxt = 0;
        del = false;
    }
    void add(int to,int c){
        st.insert({to,c});
    }
    int get(int k){
        auto it = st.upper_bound(make_pair(k,-1));
        if(it == st.end()||it->fs != k)return 0;
        return it->sc;
    }
};
const int mxn = 2e5+10;
node v[mxn];
void remov(int k){
    v[v[k].pre].nxt = v[k].nxt;
    v[v[k].nxt].pre = v[k].pre;
    v[k].del = true;
    return;
}
bool dif(int a,int b,int c){
    if(!a||!b||!c)return 0;
    if(a == b||c == b||a == c)return 0;
    return 1;
}
int pos[mxn];
vector<pii> edges;
int n;
bool cmp(pii a,pii b){
    int l1 = min(a.sc-a.fs,n-(a.sc-a.fs));
    int l2 = min(b.sc-b.fs,n-(b.sc-b.fs));
    return l1<l2;
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>n;
    string col;
    cin>>col;
    for(int i = 1;i<n;i++){
        v[i].add(i+1,col[i-1]-'0');
        v[i+1].add(i,col[i-1]-'0');
    }
    v[n].add(1,col.back()-'0');
    v[1].add(n,col.back()-'0');
    for(int i = 0;i<n-3;i++){
        int a,b,c;
        cin>>a>>b>>c;
        edges.push_back({min(a,b),max(a,b)});
        v[a].add(b,c);
        v[b].add(a,c);
    }
    for(int i = 1;i<=n;i++)v[i].pre = i-1;
    for(int i = n-1;i>=1;i--)v[i].nxt = i+1;
    v[1].pre = n;
    v[n].nxt = 1;
    sort(edges.begin(),edges.end(),cmp);
    bool flag = true;
    for(auto &i:edges){
        int a = i.fs,b = i.sc;
        if(v[a].del||v[b].del){
            cout<<"neispravna triangulacija\n";
            return 0;
        }
        if(v[v[b].pre].pre != a)swap(a,b);
        if(!dif(v[b].get(v[b].pre),v[b].get(a),v[a].get(v[b].pre))){
            flag = false;
        }
        if(v[v[b].pre].pre == a){
            remov(v[b].pre);
        }
        else{
            cout<<"neispravna triangulacija\n";
            return 0;
        }
    }
    if(flag){
        cout<<"tocno\n";
    }
    else cout<<"neispravno bojenje\n";
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12812 KB Output is correct
2 Correct 6 ms 12756 KB Output is correct
3 Correct 6 ms 12756 KB Output is correct
4 Correct 9 ms 12788 KB Output is correct
5 Correct 7 ms 12852 KB Output is correct
6 Correct 7 ms 12756 KB Output is correct
7 Correct 7 ms 12756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12812 KB Output is correct
2 Correct 6 ms 12756 KB Output is correct
3 Correct 6 ms 12756 KB Output is correct
4 Correct 9 ms 12788 KB Output is correct
5 Correct 7 ms 12852 KB Output is correct
6 Correct 7 ms 12756 KB Output is correct
7 Correct 7 ms 12756 KB Output is correct
8 Correct 8 ms 13208 KB Output is correct
9 Correct 8 ms 13268 KB Output is correct
10 Correct 8 ms 13256 KB Output is correct
11 Correct 9 ms 13252 KB Output is correct
12 Correct 8 ms 13204 KB Output is correct
13 Correct 9 ms 13244 KB Output is correct
14 Correct 9 ms 13264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 305 ms 52060 KB Output is correct
2 Correct 305 ms 52188 KB Output is correct
3 Correct 291 ms 52176 KB Output is correct
4 Correct 276 ms 55236 KB Output is correct
5 Correct 274 ms 55264 KB Output is correct
6 Correct 368 ms 55212 KB Output is correct
7 Correct 347 ms 55336 KB Output is correct
8 Correct 324 ms 55300 KB Output is correct
9 Correct 315 ms 55344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 312 ms 52140 KB Output is correct
2 Correct 312 ms 52180 KB Output is correct
3 Correct 317 ms 52104 KB Output is correct
4 Correct 329 ms 52132 KB Output is correct
5 Correct 338 ms 52172 KB Output is correct
6 Correct 390 ms 52184 KB Output is correct
7 Correct 359 ms 52288 KB Output is correct
8 Correct 368 ms 52168 KB Output is correct
9 Correct 356 ms 52228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12812 KB Output is correct
2 Correct 6 ms 12756 KB Output is correct
3 Correct 6 ms 12756 KB Output is correct
4 Correct 9 ms 12788 KB Output is correct
5 Correct 7 ms 12852 KB Output is correct
6 Correct 7 ms 12756 KB Output is correct
7 Correct 7 ms 12756 KB Output is correct
8 Correct 8 ms 13208 KB Output is correct
9 Correct 8 ms 13268 KB Output is correct
10 Correct 8 ms 13256 KB Output is correct
11 Correct 9 ms 13252 KB Output is correct
12 Correct 8 ms 13204 KB Output is correct
13 Correct 9 ms 13244 KB Output is correct
14 Correct 9 ms 13264 KB Output is correct
15 Correct 305 ms 52060 KB Output is correct
16 Correct 305 ms 52188 KB Output is correct
17 Correct 291 ms 52176 KB Output is correct
18 Correct 276 ms 55236 KB Output is correct
19 Correct 274 ms 55264 KB Output is correct
20 Correct 368 ms 55212 KB Output is correct
21 Correct 347 ms 55336 KB Output is correct
22 Correct 324 ms 55300 KB Output is correct
23 Correct 315 ms 55344 KB Output is correct
24 Correct 312 ms 52140 KB Output is correct
25 Correct 312 ms 52180 KB Output is correct
26 Correct 317 ms 52104 KB Output is correct
27 Correct 329 ms 52132 KB Output is correct
28 Correct 338 ms 52172 KB Output is correct
29 Correct 390 ms 52184 KB Output is correct
30 Correct 359 ms 52288 KB Output is correct
31 Correct 368 ms 52168 KB Output is correct
32 Correct 356 ms 52228 KB Output is correct
33 Correct 308 ms 55244 KB Output is correct
34 Correct 316 ms 55276 KB Output is correct
35 Correct 305 ms 55228 KB Output is correct
36 Correct 286 ms 55240 KB Output is correct
37 Correct 321 ms 55220 KB Output is correct
38 Correct 314 ms 55200 KB Output is correct
39 Correct 319 ms 55344 KB Output is correct
40 Correct 367 ms 55252 KB Output is correct
41 Correct 347 ms 55284 KB Output is correct
42 Correct 324 ms 55204 KB Output is correct
43 Correct 364 ms 55244 KB Output is correct