Submission #1110828

# Submission time Handle Problem Language Result Execution time Memory
1110828 2024-11-10T14:59:22 Z Pioneer Sphinx's Riddle (IOI24_sphinx) C++17
50 / 100
388 ms 1200 KB
#include "sphinx.h"
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define sz(s) ((int)s.size())
#define all(v) v.begin(),v.end()

const int MAX=255;

struct dsu{
    int f[MAX];

    void init(int n){
        for(int i=0;i<n;i++)f[i]=i;
    }

    int get(int v){
        return (f[v]==v?v:f[v]=get(f[v]));
    }

    void unite(int a,int b){
        a=get(a),b=get(b);
        f[a]=b;
    }
}d,dd;

int n;
vector<int> g[MAX];

bool bar(int mid,int l,int r){
    vector<int> ask(n,-1);
    for(int i=0;i<mid;i++){
        if(d.get(i)<l||d.get(i)>r){
            ask[i]=n;
        }
    }
    for(int i=mid+1;i<n;i++)ask[i]=n;
    dd.init(n);
    for(int i=0;i<n;i++){
        for(auto to:g[i]){
            if(ask[i]==n&&ask[to]==n){
                dd.unite(i,to);
            }
        }
    }
    for(int i=0;i<mid;i++){
        for(auto to:g[i]){
            if(d.get(i)==d.get(to)){
                dd.unite(i,to);
            }
        }
    }
    vector<int> vec;
    for(int i=0;i<n;i++)vec.pb(dd.get(i));
    sort(all(vec));
    vec.erase(unique(all(vec)),vec.end());
    return (sz(vec)!=perform_experiment(ask));
}

vector<int> find_colours(int N,vector<int> X,vector<int> Y){
    n=N;
    for(int i=0;i<sz(X);i++){
        g[X[i]].pb(Y[i]);
        g[Y[i]].pb(X[i]);
    }
    d.init(n);
    for(int i=1;i<N;i++){
        vector<int> v;
        for(auto to:g[i]){
            if(to<i){
                v.pb(d.get(to));
            }
        }
        sort(all(v));
        v.erase(unique(all(v)),v.end());
        int l=0;
        vector<int> mrg;
        while(l<sz(v)&&bar(i,v[l],v.back())){
            int r=sz(v)-2,res=sz(v)-1;
            int L=l;
            while(L<=r){
                int mid=(L+r)/2;
                if(bar(i,v[l],v[mid])){
                    r=mid-1;
                    res=mid;
                }
                else{
                    L=mid+1;
                }
            }
            l=res+1;
            mrg.pb(v[res]);
        }
        for(auto to:mrg){
            d.unite(i,to);
        }
    }
    vector<int> ans(n);
    for(int i=0;i<n;i++)ans[i]=d.get(i);
    return ans;
}
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 336 KB Partially correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB #experiments: 1
2 Correct 1 ms 336 KB #experiments: 1
3 Partially correct 1 ms 336 KB Partially correct
4 Partially correct 1 ms 336 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 336 KB Partially correct
2 Correct 1 ms 336 KB #experiments: 1
3 Correct 1 ms 336 KB #experiments: 1
4 Partially correct 1 ms 336 KB Partially correct
5 Partially correct 1 ms 336 KB Partially correct
6 Partially correct 2 ms 336 KB Partially correct
7 Partially correct 2 ms 336 KB Partially correct
8 Partially correct 2 ms 336 KB Partially correct
9 Partially correct 2 ms 336 KB Partially correct
10 Partially correct 2 ms 336 KB Partially correct
11 Partially correct 2 ms 336 KB Partially correct
12 Partially correct 2 ms 588 KB Partially correct
13 Partially correct 2 ms 336 KB Partially correct
14 Partially correct 2 ms 420 KB Partially correct
15 Partially correct 6 ms 336 KB Partially correct
16 Partially correct 7 ms 336 KB Partially correct
17 Partially correct 7 ms 336 KB Partially correct
18 Partially correct 7 ms 336 KB Partially correct
19 Partially correct 6 ms 336 KB Partially correct
20 Partially correct 5 ms 336 KB Partially correct
21 Partially correct 2 ms 336 KB Partially correct
22 Partially correct 2 ms 336 KB Partially correct
23 Partially correct 3 ms 336 KB Partially correct
24 Partially correct 2 ms 336 KB Partially correct
25 Partially correct 2 ms 336 KB Partially correct
26 Partially correct 2 ms 336 KB Partially correct
27 Partially correct 2 ms 336 KB Partially correct
28 Partially correct 1 ms 336 KB Partially correct
29 Partially correct 4 ms 336 KB Partially correct
30 Partially correct 3 ms 336 KB Partially correct
31 Partially correct 7 ms 336 KB Partially correct
32 Partially correct 5 ms 336 KB Partially correct
33 Partially correct 3 ms 336 KB Partially correct
34 Partially correct 2 ms 336 KB Partially correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB #experiments: 1
2 Correct 1 ms 336 KB #experiments: 1
3 Partially correct 1 ms 336 KB Partially correct
4 Partially correct 1 ms 336 KB Partially correct
5 Partially correct 2 ms 336 KB Partially correct
6 Partially correct 2 ms 336 KB Partially correct
7 Partially correct 2 ms 336 KB Partially correct
8 Partially correct 2 ms 336 KB Partially correct
9 Partially correct 2 ms 336 KB Partially correct
10 Partially correct 2 ms 336 KB Partially correct
11 Partially correct 2 ms 588 KB Partially correct
12 Partially correct 2 ms 336 KB Partially correct
13 Partially correct 9 ms 500 KB Partially correct
14 Partially correct 9 ms 336 KB Partially correct
15 Partially correct 14 ms 336 KB Partially correct
16 Partially correct 15 ms 504 KB Partially correct
17 Partially correct 9 ms 336 KB Partially correct
18 Partially correct 10 ms 336 KB Partially correct
19 Partially correct 15 ms 336 KB Partially correct
20 Partially correct 9 ms 336 KB Partially correct
21 Partially correct 9 ms 336 KB Partially correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB #experiments: 1
2 Correct 1 ms 336 KB #experiments: 1
3 Partially correct 1 ms 336 KB Partially correct
4 Partially correct 1 ms 336 KB Partially correct
5 Partially correct 2 ms 420 KB Partially correct
6 Partially correct 6 ms 336 KB Partially correct
7 Partially correct 7 ms 336 KB Partially correct
8 Partially correct 7 ms 336 KB Partially correct
9 Partially correct 7 ms 336 KB Partially correct
10 Partially correct 6 ms 336 KB Partially correct
11 Partially correct 5 ms 336 KB Partially correct
12 Partially correct 2 ms 336 KB Partially correct
13 Partially correct 118 ms 1104 KB Partially correct
14 Partially correct 226 ms 1196 KB Partially correct
15 Partially correct 304 ms 1196 KB Partially correct
16 Partially correct 309 ms 1196 KB Partially correct
17 Partially correct 291 ms 1196 KB Partially correct
18 Partially correct 248 ms 1104 KB Partially correct
19 Partially correct 178 ms 1200 KB Partially correct
20 Partially correct 57 ms 1192 KB Partially correct
21 Partially correct 36 ms 1104 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 336 KB Partially correct
2 Correct 1 ms 336 KB #experiments: 1
3 Correct 1 ms 336 KB #experiments: 1
4 Partially correct 1 ms 336 KB Partially correct
5 Partially correct 1 ms 336 KB Partially correct
6 Partially correct 2 ms 336 KB Partially correct
7 Partially correct 2 ms 336 KB Partially correct
8 Partially correct 2 ms 336 KB Partially correct
9 Partially correct 2 ms 336 KB Partially correct
10 Partially correct 2 ms 336 KB Partially correct
11 Partially correct 2 ms 336 KB Partially correct
12 Partially correct 2 ms 588 KB Partially correct
13 Partially correct 2 ms 336 KB Partially correct
14 Partially correct 2 ms 420 KB Partially correct
15 Partially correct 6 ms 336 KB Partially correct
16 Partially correct 7 ms 336 KB Partially correct
17 Partially correct 7 ms 336 KB Partially correct
18 Partially correct 7 ms 336 KB Partially correct
19 Partially correct 6 ms 336 KB Partially correct
20 Partially correct 5 ms 336 KB Partially correct
21 Partially correct 2 ms 336 KB Partially correct
22 Partially correct 2 ms 336 KB Partially correct
23 Partially correct 3 ms 336 KB Partially correct
24 Partially correct 2 ms 336 KB Partially correct
25 Partially correct 2 ms 336 KB Partially correct
26 Partially correct 2 ms 336 KB Partially correct
27 Partially correct 2 ms 336 KB Partially correct
28 Partially correct 1 ms 336 KB Partially correct
29 Partially correct 4 ms 336 KB Partially correct
30 Partially correct 3 ms 336 KB Partially correct
31 Partially correct 7 ms 336 KB Partially correct
32 Partially correct 5 ms 336 KB Partially correct
33 Partially correct 3 ms 336 KB Partially correct
34 Partially correct 2 ms 336 KB Partially correct
35 Partially correct 9 ms 500 KB Partially correct
36 Partially correct 9 ms 336 KB Partially correct
37 Partially correct 14 ms 336 KB Partially correct
38 Partially correct 15 ms 504 KB Partially correct
39 Partially correct 9 ms 336 KB Partially correct
40 Partially correct 10 ms 336 KB Partially correct
41 Partially correct 15 ms 336 KB Partially correct
42 Partially correct 9 ms 336 KB Partially correct
43 Partially correct 9 ms 336 KB Partially correct
44 Partially correct 118 ms 1104 KB Partially correct
45 Partially correct 226 ms 1196 KB Partially correct
46 Partially correct 304 ms 1196 KB Partially correct
47 Partially correct 309 ms 1196 KB Partially correct
48 Partially correct 291 ms 1196 KB Partially correct
49 Partially correct 248 ms 1104 KB Partially correct
50 Partially correct 178 ms 1200 KB Partially correct
51 Partially correct 57 ms 1192 KB Partially correct
52 Partially correct 36 ms 1104 KB Partially correct
53 Partially correct 34 ms 336 KB Partially correct
54 Partially correct 54 ms 336 KB Partially correct
55 Partially correct 59 ms 336 KB Partially correct
56 Partially correct 85 ms 336 KB Partially correct
57 Partially correct 29 ms 592 KB Partially correct
58 Partially correct 22 ms 592 KB Partially correct
59 Partially correct 20 ms 592 KB Partially correct
60 Partially correct 25 ms 592 KB Partially correct
61 Partially correct 8 ms 336 KB Partially correct
62 Partially correct 7 ms 336 KB Partially correct
63 Partially correct 9 ms 336 KB Partially correct
64 Partially correct 74 ms 336 KB Partially correct
65 Partially correct 71 ms 336 KB Partially correct
66 Partially correct 83 ms 336 KB Partially correct
67 Partially correct 80 ms 336 KB Partially correct
68 Partially correct 102 ms 336 KB Partially correct
69 Partially correct 95 ms 336 KB Partially correct
70 Partially correct 87 ms 336 KB Partially correct
71 Partially correct 115 ms 508 KB Partially correct
72 Partially correct 33 ms 336 KB Partially correct
73 Partially correct 54 ms 508 KB Partially correct
74 Partially correct 52 ms 508 KB Partially correct
75 Partially correct 88 ms 336 KB Partially correct
76 Partially correct 80 ms 336 KB Partially correct
77 Partially correct 92 ms 504 KB Partially correct
78 Partially correct 97 ms 336 KB Partially correct
79 Partially correct 131 ms 592 KB Partially correct
80 Partially correct 124 ms 592 KB Partially correct
81 Partially correct 112 ms 592 KB Partially correct
82 Partially correct 37 ms 592 KB Partially correct
83 Partially correct 388 ms 848 KB Partially correct
84 Partially correct 231 ms 1104 KB Partially correct
85 Partially correct 27 ms 592 KB Partially correct
86 Partially correct 25 ms 592 KB Partially correct