# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
507622 | Hanksburger | Simurgh (IOI17_simurgh) | C++17 | 6 ms | 288 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
bool chosen[25], selected[10];
vector<int> UU, VV, ans;
int NN, cnt;
bool recur(int X, int Y)
{
if (X==NN-1)
{
ans.clear();
cnt++;
for (int i=0; i<UU.size(); i++)
if (chosen[i])
ans.push_back(i);
if (count_common_roads(ans)==NN-1)
return 1;
else
return 0;
}
for (int i=Y; i<UU.size(); i++)
{
if (!chosen[i])
{
if (X==0)
{
chosen[i]=1;
selected[UU[i]]=1;
selected[VV[i]]=1;
if (recur(X+1, i+1))
return 1;
chosen[i]=0;
selected[UU[i]]=0;
selected[VV[i]]=0;
continue;
}
if (selected[UU[i]] && !selected[VV[i]])
{
chosen[i]=1;
selected[VV[i]]=1;
if (recur(X+1, i+1))
return 1;
chosen[i]=0;
selected[VV[i]]=0;
}
else if (!selected[UU[i]] && selected[VV[i]])
{
chosen[i]=1;
selected[UU[i]]=1;
if (recur(X+1, i+1))
return 1;
chosen[i]=0;
selected[UU[i]]=0;
}
}
}
return 0;
}
vector<int> find_roads(int N, vector<int> U, vector<int> V)
{
if (N<=7)
{
NN=N;
UU=U;
VV=V;
recur(0, 0);
return ans;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |