답안 #968711

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
968711 2024-04-23T22:28:20 Z MarwenElarbi Simurgh (IOI17_simurgh) C++17
0 / 100
22 ms 600 KB
#include <bits/stdc++.h>
#include "simurgh.h"
using namespace std;
int count_common_roads(const std::vector<int>& r);
vector<int> adj[250];
vector<int> p(250);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int f(int x){
    if(x==p[x]) return x;
    return p[x]=f(p[x]);
}
bool sameset(int x,int y){
    return f(x)==f(y);
}
void joinset(int x,int y){
    x=f(x);
    y=f(y);
    p[x]=y;
}
std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v){
    int m=u.size();
    vector<int> permutation(m);
    for (int i = 0; i < m; ++i)
    {
        permutation[i]=i;
    }
    while(true){
        vector<int> cur;
        shuffle(permutation.begin(),permutation.end(),rng);
        /*for (int i = 0; i < m; ++i)
        {
            cout <<permutation[i]<<" ";
        }cout <<endl;*/
        for (int i = 0; i < n; ++i)
        {
            p[i]=i;
        }
        for (int i = 0; i < m; ++i)
        {
            int x=u[permutation[i]];
            int y=v[permutation[i]];
            if(!sameset(x,y)){
                joinset(x,y);
                cur.push_back(permutation[i]);
            }
        }
        /*for (int i = 0; i < n-1; ++i)
        {
            cout <<cur[i]<<" ";
        }cout <<endl;*/
        int cnt=count_common_roads(cur);
        
        if(cnt==n-1) return(cur);       
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 348 KB correct
2 Correct 1 ms 344 KB correct
3 Correct 1 ms 600 KB correct
4 Correct 1 ms 348 KB correct
5 Correct 0 ms 348 KB correct
6 Correct 1 ms 344 KB correct
7 Correct 0 ms 448 KB correct
8 Correct 0 ms 348 KB correct
9 Correct 0 ms 348 KB correct
10 Correct 1 ms 344 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 2 ms 348 KB correct
13 Incorrect 22 ms 344 KB WA in grader: NO
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 348 KB correct
2 Correct 1 ms 344 KB correct
3 Correct 1 ms 600 KB correct
4 Correct 1 ms 348 KB correct
5 Correct 0 ms 348 KB correct
6 Correct 1 ms 344 KB correct
7 Correct 0 ms 448 KB correct
8 Correct 0 ms 348 KB correct
9 Correct 0 ms 348 KB correct
10 Correct 1 ms 344 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 2 ms 348 KB correct
13 Incorrect 22 ms 344 KB WA in grader: NO
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 348 KB correct
2 Correct 1 ms 344 KB correct
3 Correct 1 ms 600 KB correct
4 Correct 1 ms 348 KB correct
5 Correct 0 ms 348 KB correct
6 Correct 1 ms 344 KB correct
7 Correct 0 ms 448 KB correct
8 Correct 0 ms 348 KB correct
9 Correct 0 ms 348 KB correct
10 Correct 1 ms 344 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 2 ms 348 KB correct
13 Incorrect 22 ms 344 KB WA in grader: NO
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB correct
2 Incorrect 17 ms 348 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 348 KB correct
2 Correct 1 ms 344 KB correct
3 Correct 1 ms 600 KB correct
4 Correct 1 ms 348 KB correct
5 Correct 0 ms 348 KB correct
6 Correct 1 ms 344 KB correct
7 Correct 0 ms 448 KB correct
8 Correct 0 ms 348 KB correct
9 Correct 0 ms 348 KB correct
10 Correct 1 ms 344 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 2 ms 348 KB correct
13 Incorrect 22 ms 344 KB WA in grader: NO
14 Halted 0 ms 0 KB -