Submission #34135

# Submission time Handle Problem Language Result Execution time Memory
34135 2017-11-07T17:39:12 Z bnahmad15 Simurgh (IOI17_simurgh) C++14
13 / 100
13 ms 2048 KB
#include "simurgh.h"
#include <bits/stdc++.h>
#define forn(i,n) for (int i = 0;i<int(n);i++)
#define ff first
#define ss second
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> ppi;

int n,m;
bool flag = false;
vector <int> adj[1000],ans,u,v;
bool vis[10]={false};
int check(int idx){
    vis[idx]=true;
    int tmp = 0;
    forn(i,adj[idx].size()){
        int to = adj[idx][i];
        if (vis[to])
            continue;
        tmp += check(to) + 1;
    }
    return tmp;
}
vector<int> vec(int ar){
    vector<int> res;
    forn(i,32){
        if ((1<<i)&ar)
            res.push_back(i);
    }
    return res;
}
void _try(int idx,int num,int sor){
    if (num == n-1){
        fill(vis,vis+10,false);
        if (check(0)==n-1){
            if (count_common_roads(vec(sor)) == n-1){
                ans = vec(sor);
                flag = true;
            }
        }
        return;
    }
    if (idx == m)
        return;
    adj[u[idx]].push_back(v[idx]);
    adj[v[idx]].push_back(u[idx]);
    _try(idx+1,num+1,sor | (1<<idx));
    adj[u[idx]].pop_back();
    adj[v[idx]].pop_back();
    if (flag)
        return;
    _try(idx+1,num,sor);
}
std::vector<int> find_roads(int N, std::vector<int> U, std::vector<int> V) {
    n = N;
    u=U,v=V;
    m=u.size();
    _try(0,0,0);
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 13 ms 2048 KB correct
2 Correct 0 ms 2048 KB correct
3 Correct 6 ms 2048 KB correct
4 Correct 0 ms 2048 KB correct
5 Correct 0 ms 2048 KB correct
6 Correct 0 ms 2048 KB correct
7 Correct 0 ms 2048 KB correct
8 Correct 0 ms 2048 KB correct
9 Correct 0 ms 2048 KB correct
10 Correct 0 ms 2048 KB correct
11 Correct 0 ms 2048 KB correct
12 Correct 0 ms 2048 KB correct
13 Correct 6 ms 2048 KB correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 2048 KB correct
2 Correct 0 ms 2048 KB correct
3 Correct 6 ms 2048 KB correct
4 Correct 0 ms 2048 KB correct
5 Correct 0 ms 2048 KB correct
6 Correct 0 ms 2048 KB correct
7 Correct 0 ms 2048 KB correct
8 Correct 0 ms 2048 KB correct
9 Correct 0 ms 2048 KB correct
10 Correct 0 ms 2048 KB correct
11 Correct 0 ms 2048 KB correct
12 Correct 0 ms 2048 KB correct
13 Correct 6 ms 2048 KB correct
14 Runtime error 0 ms 2048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 2048 KB correct
2 Correct 0 ms 2048 KB correct
3 Correct 6 ms 2048 KB correct
4 Correct 0 ms 2048 KB correct
5 Correct 0 ms 2048 KB correct
6 Correct 0 ms 2048 KB correct
7 Correct 0 ms 2048 KB correct
8 Correct 0 ms 2048 KB correct
9 Correct 0 ms 2048 KB correct
10 Correct 0 ms 2048 KB correct
11 Correct 0 ms 2048 KB correct
12 Correct 0 ms 2048 KB correct
13 Correct 6 ms 2048 KB correct
14 Runtime error 0 ms 2048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2048 KB correct
2 Incorrect 13 ms 2048 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 2048 KB correct
2 Correct 0 ms 2048 KB correct
3 Correct 6 ms 2048 KB correct
4 Correct 0 ms 2048 KB correct
5 Correct 0 ms 2048 KB correct
6 Correct 0 ms 2048 KB correct
7 Correct 0 ms 2048 KB correct
8 Correct 0 ms 2048 KB correct
9 Correct 0 ms 2048 KB correct
10 Correct 0 ms 2048 KB correct
11 Correct 0 ms 2048 KB correct
12 Correct 0 ms 2048 KB correct
13 Correct 6 ms 2048 KB correct
14 Runtime error 0 ms 2048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Halted 0 ms 0 KB -