QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#511338 | #5450. 比赛 | Rafi22# | 6 | 220ms | 3756kb | C++14 | 1.8kb | 2024-08-09 19:14:54 | 2024-08-09 19:14:54 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif
#define ll long long
#define ld long double
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
#define ROF(i,r,l) for(int i=(r);i>=(l);i--)
int inf=1000000007;
ll infl=1000000000000000007;
ll mod=1000000007;
ll mod1=998244353;
const int N=57;
bool is[N][N];
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tt;
cin>>tt;
while(tt--)
{
int n,m;
cin>>n>>m;
FOR(i,1,m)
{
int x;
cin>>x;
while(x--)
{
int k;
cin>>k;
is[i][k]=1;
}
}
vector<int>p(n);
FOR(i,1,n) p[i-1]=i;
bool ans=0;
while(true)
{
bool ok=1;
FOR(i,1,m)
{
FOR(j,0,n-1) if(is[i][p[j]]&&is[i][p[(j+1)%n]]&&is[i][p[(j+2)%n]]) ok=0;
}
if(ok)
{
ans=1;
break;
}
if(!next_permutation(all(p))) break;
}
if(!ans) cout<<-1<<endl;
else
{
for(auto x:p) cout<<x<<" ";
cout<<endl;
}
memset(is,0,sizeof is);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 6
Accepted
Test #1:
score: 6
Accepted
time: 88ms
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 1 5 4 0 7 4 3 5 4 2 4 7 2 ...
output:
1 2 3 5 4 7 6 8 -1 -1 1 2 3 4 5 8 6 7 9 1 2 3 4 5 6 7 1 2 3 4 -1 1 2 4 3 7 5 8 6 1 2 3 1 2 3 4 5 7 6 1 2 3 6 5 7 4 1 2 3 4 1 2 3 4 5 6 7 -1 1 2 3 5 4 6 -1 1 2 3 4 5 6 1 2 4 3 6 5 1 2 4 3 5 6 -1 1 2 3 4 6 5 7 1 2 3 4 5 6 8 7 9 1 2 3 5 4 7 6 9 8 1 2 3 1 2 3 4 5 1 2 3 4 5 6 7 8 1 2 ...
result:
ok 336 testcases
Subtask #2:
score: 0
Time Limit Exceeded
Dependency #1:
100%
Accepted
Test #8:
score: 0
Time Limit Exceeded
input:
2 12 3 7 1 3 4 8 9 11 12 3 1 5 6 3 6 7 12 15 1 10 1 2 3 4 5 6 7 8 9 10
output:
result:
Subtask #3:
score: 0
Runtime Error
Dependency #1:
100%
Accepted
Test #17:
score: 0
Runtime Error
input:
66 43 106 3 42 1 38 4 3 16 13 39 3 42 37 8 3 5 2 37 3 35 40 19 4 8 10 6 12 3 2 42 32 3 8 28 5 3 37 11 31 3 35 1 30 3 12 24 26 5 13 1 5 12 36 3 24 37 43 4 16 34 20 17 3 34 30 2 3 16 1 10 3 20 3 19 3 28 31 35 3 2 27 3 4 36 16 24 30 3 7 4 24 3 41 14 31 3 23 14 16 4 36 26 17 42 3 29 37 3 3 1 40 3 3 20 2...
output:
result:
Subtask #4:
score: 0
Time Limit Exceeded
Test #25:
score: 0
Time Limit Exceeded
input:
5 400 1 266 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...
output:
result:
Subtask #5:
score: 0
Time Limit Exceeded
Test #36:
score: 0
Time Limit Exceeded
input:
5 400 1 266 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...
output:
result:
Subtask #6:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%
Subtask #7:
score: 0
Skipped
Dependency #4:
0%
Subtask #8:
score: 0
Skipped
Dependency #5:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%