Submission #366052

# Submission time Handle Problem Language Result Execution time Memory
366052 2021-02-12T20:54:41 Z denkendoemeer Simurgh (IOI17_simurgh) C++14
51 / 100
199 ms 3940 KB
#include "simurgh.h"
#include<bits/stdc++.h>
using namespace std;
vector<int>ans,poz,poz2,g,g2;
int t[505],n,m;
void init()
{
    int i;
    for(i=0;i<n;i++)
        t[i]=i;
}
int findt(int nod)
{
    if (nod==t[nod])
        return nod;
    return t[nod]=findt(t[nod]);
}
void onion(int x,int y)
{
    x=findt(x);
    y=findt(y);
    t[x]=y;
}
void calc()
{
    init();
    int cnt=n;
    vector<int>aux;
    vector<pair<int,int>>auxi;
    for(auto it:ans){
        onion(g[it],g2[it]);
        aux.push_back(it);
        cnt--;
    }
    for(auto it:poz){
        if (cnt==2){
            if (findt(g[it])!=findt(g2[it])){
                aux.push_back(it);
                int nr=count_common_roads(aux);
                auxi.push_back({nr,it});
                aux.pop_back();
            }
            else
                poz2.push_back(it);
        }
        else{
            if (findt(g[it])!=findt(g2[it])){
                aux.push_back(it);
                onion(g[it],g2[it]);
                cnt--;
            }
            poz2.push_back(it);
        }
    }
    pair<int,int>maxi=*max_element(auxi.begin(),auxi.end());
    for(auto it:auxi)
        if (it.first==maxi.first)
            ans.push_back(it.second);
    swap(poz,poz2);
    poz2.clear();
}
vector<int> find_roads(int n2,vector<int>x,vector<int>y)
{
    m=x.size();
    n=n2;
    g=x;
    g2=y;
    int i;
    for(i=0;i<m;i++)
        poz.push_back(i);
    while(ans.size()<n-1)
        calc();
    return ans;
}

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:71:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   71 |     while(ans.size()<n-1)
      |           ~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB correct
2 Correct 1 ms 364 KB correct
3 Correct 1 ms 364 KB correct
4 Correct 1 ms 364 KB correct
5 Correct 1 ms 364 KB correct
6 Correct 1 ms 364 KB correct
7 Correct 1 ms 364 KB correct
8 Correct 1 ms 364 KB correct
9 Correct 1 ms 364 KB correct
10 Correct 1 ms 364 KB correct
11 Correct 1 ms 364 KB correct
12 Correct 0 ms 364 KB correct
13 Correct 1 ms 364 KB correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB correct
2 Correct 1 ms 364 KB correct
3 Correct 1 ms 364 KB correct
4 Correct 1 ms 364 KB correct
5 Correct 1 ms 364 KB correct
6 Correct 1 ms 364 KB correct
7 Correct 1 ms 364 KB correct
8 Correct 1 ms 364 KB correct
9 Correct 1 ms 364 KB correct
10 Correct 1 ms 364 KB correct
11 Correct 1 ms 364 KB correct
12 Correct 0 ms 364 KB correct
13 Correct 1 ms 364 KB correct
14 Correct 2 ms 364 KB correct
15 Correct 2 ms 364 KB correct
16 Correct 2 ms 364 KB correct
17 Correct 2 ms 364 KB correct
18 Correct 1 ms 364 KB correct
19 Correct 2 ms 364 KB correct
20 Correct 2 ms 364 KB correct
21 Correct 2 ms 364 KB correct
22 Correct 2 ms 364 KB correct
23 Correct 2 ms 364 KB correct
24 Correct 2 ms 384 KB correct
25 Correct 1 ms 364 KB correct
26 Correct 2 ms 364 KB correct
27 Correct 2 ms 364 KB correct
28 Correct 1 ms 364 KB correct
29 Correct 1 ms 364 KB correct
30 Correct 2 ms 364 KB correct
31 Correct 2 ms 364 KB correct
32 Correct 1 ms 364 KB correct
33 Correct 1 ms 364 KB correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB correct
2 Correct 1 ms 364 KB correct
3 Correct 1 ms 364 KB correct
4 Correct 1 ms 364 KB correct
5 Correct 1 ms 364 KB correct
6 Correct 1 ms 364 KB correct
7 Correct 1 ms 364 KB correct
8 Correct 1 ms 364 KB correct
9 Correct 1 ms 364 KB correct
10 Correct 1 ms 364 KB correct
11 Correct 1 ms 364 KB correct
12 Correct 0 ms 364 KB correct
13 Correct 1 ms 364 KB correct
14 Correct 2 ms 364 KB correct
15 Correct 2 ms 364 KB correct
16 Correct 2 ms 364 KB correct
17 Correct 2 ms 364 KB correct
18 Correct 1 ms 364 KB correct
19 Correct 2 ms 364 KB correct
20 Correct 2 ms 364 KB correct
21 Correct 2 ms 364 KB correct
22 Correct 2 ms 364 KB correct
23 Correct 2 ms 364 KB correct
24 Correct 2 ms 384 KB correct
25 Correct 1 ms 364 KB correct
26 Correct 2 ms 364 KB correct
27 Correct 2 ms 364 KB correct
28 Correct 1 ms 364 KB correct
29 Correct 1 ms 364 KB correct
30 Correct 2 ms 364 KB correct
31 Correct 2 ms 364 KB correct
32 Correct 1 ms 364 KB correct
33 Correct 1 ms 364 KB correct
34 Correct 199 ms 1516 KB correct
35 Correct 183 ms 1516 KB correct
36 Correct 130 ms 1132 KB correct
37 Correct 10 ms 364 KB correct
38 Correct 181 ms 1516 KB correct
39 Correct 176 ms 1388 KB correct
40 Correct 138 ms 1260 KB correct
41 Correct 96 ms 1608 KB correct
42 Correct 170 ms 1516 KB correct
43 Correct 94 ms 1004 KB correct
44 Correct 79 ms 876 KB correct
45 Correct 91 ms 1004 KB correct
46 Correct 72 ms 876 KB correct
47 Correct 34 ms 512 KB correct
48 Correct 5 ms 364 KB correct
49 Correct 11 ms 364 KB correct
50 Correct 31 ms 492 KB correct
51 Correct 96 ms 1004 KB correct
52 Correct 81 ms 876 KB correct
53 Correct 75 ms 876 KB correct
54 Correct 93 ms 1132 KB correct
55 Correct 82 ms 1132 KB correct
56 Correct 82 ms 1004 KB correct
57 Correct 78 ms 1036 KB correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB correct
2 Correct 1 ms 364 KB correct
3 Incorrect 174 ms 3940 KB WA in grader: NO
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB correct
2 Correct 1 ms 364 KB correct
3 Correct 1 ms 364 KB correct
4 Correct 1 ms 364 KB correct
5 Correct 1 ms 364 KB correct
6 Correct 1 ms 364 KB correct
7 Correct 1 ms 364 KB correct
8 Correct 1 ms 364 KB correct
9 Correct 1 ms 364 KB correct
10 Correct 1 ms 364 KB correct
11 Correct 1 ms 364 KB correct
12 Correct 0 ms 364 KB correct
13 Correct 1 ms 364 KB correct
14 Correct 2 ms 364 KB correct
15 Correct 2 ms 364 KB correct
16 Correct 2 ms 364 KB correct
17 Correct 2 ms 364 KB correct
18 Correct 1 ms 364 KB correct
19 Correct 2 ms 364 KB correct
20 Correct 2 ms 364 KB correct
21 Correct 2 ms 364 KB correct
22 Correct 2 ms 364 KB correct
23 Correct 2 ms 364 KB correct
24 Correct 2 ms 384 KB correct
25 Correct 1 ms 364 KB correct
26 Correct 2 ms 364 KB correct
27 Correct 2 ms 364 KB correct
28 Correct 1 ms 364 KB correct
29 Correct 1 ms 364 KB correct
30 Correct 2 ms 364 KB correct
31 Correct 2 ms 364 KB correct
32 Correct 1 ms 364 KB correct
33 Correct 1 ms 364 KB correct
34 Correct 199 ms 1516 KB correct
35 Correct 183 ms 1516 KB correct
36 Correct 130 ms 1132 KB correct
37 Correct 10 ms 364 KB correct
38 Correct 181 ms 1516 KB correct
39 Correct 176 ms 1388 KB correct
40 Correct 138 ms 1260 KB correct
41 Correct 96 ms 1608 KB correct
42 Correct 170 ms 1516 KB correct
43 Correct 94 ms 1004 KB correct
44 Correct 79 ms 876 KB correct
45 Correct 91 ms 1004 KB correct
46 Correct 72 ms 876 KB correct
47 Correct 34 ms 512 KB correct
48 Correct 5 ms 364 KB correct
49 Correct 11 ms 364 KB correct
50 Correct 31 ms 492 KB correct
51 Correct 96 ms 1004 KB correct
52 Correct 81 ms 876 KB correct
53 Correct 75 ms 876 KB correct
54 Correct 93 ms 1132 KB correct
55 Correct 82 ms 1132 KB correct
56 Correct 82 ms 1004 KB correct
57 Correct 78 ms 1036 KB correct
58 Correct 1 ms 364 KB correct
59 Correct 1 ms 364 KB correct
60 Incorrect 174 ms 3940 KB WA in grader: NO
61 Halted 0 ms 0 KB -