QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#511330#5450. 比赛Rafi22#0 0ms4480kbC++142.2kb2024-08-09 19:02:182024-08-09 19:02:19

Judging History

你现在查看的是最新测评结果

  • [2024-08-09 19:02:19]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:4480kb
  • [2024-08-09 19:02:18]
  • 提交

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=2007;

int ile[N];
bool is[N][N];
bool odw[N];
int res[N];

int main()
{
    int tt;
    cin>>tt;
    while(tt--)
    {
        int n,m;
        cin>>n>>m;
        bool ok=1;
        FOR(i,1,m)
        {
            cin>>ile[i];
            if(ile[i]>2*n/3) ok=0;
            FOR(j,1,ile[i])
            {
                int x;
                cin>>x;
                is[x][i]=1;
            }
        }
        if(ok)
        {
            FOR(k,1,n)
            {
                int ban=0;
                FOR(i,1,m)
                {
                    if(k>=3&&is[res[k-1]][i]&&is[res[k-2]][i]) ban=i;
                }
                debug(ban);
                int mx=0,t=-1;
                FOR(i,1,n)
                {
                    if(odw[i]||is[i][ban]) continue;
                    int act=0;
                    FOR(j,1,m) if(is[i][j]) act=max(act,ile[j]);
                    if(act>mx)
                    {
                        t=i;
                        mx=act;
                    }
                }
                res[k]=t;
                debug(k,t);
                odw[t]=1;
                FOR(j,1,m) if(is[t][j]) ile[j]--;
            }
            FOR(i,1,n) cout<<res[i]<<" ";
            cout<<endl;
        }
        else cout<<-1<<endl;
        FOR(i,1,n)
        {
            odw[i]=0;
            FOR(j,1,m) is[i][j]=0;
        }
    }
    return 0;
}







Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3696kb

input:

248
9 3
3 3 4 5
3 1 2 3
4 6 7 8 9
8 1
4 3 4 5 6
9 2
5 1 2 3 4 5
3 6 7 8
6 1
4 3 4 5 6
7 2
3 3 4 5
3 1 2 3
9 3
4 1 2 3 4
3 4 5 6
3 6 7 8
7 1
4 4 5 6 7
8 2
3 6 7 8
3 2 3 4
8 2
4 1 2 3 4
4 4 5 6 7
3 0
9 3
3 2 3 4
3 7 8 9
3 4 5 6
6 1
5 1 2 3 4 5
9 2
4 1 2 3 4
3 6 7 8
9 3
3 6 7 8
3 3 4 5
3 1 2 3
8 1
8 1 ...

output:

6 1 3 7 4 8 2 5 9 
3 4 -1 5 6 -1 -1 -1 
1 2 6 3 4 7 5 8 -1 
3 4 -1 5 6 -1 
1 3 4 2 5 -1 -1 
1 2 5 6 3 7 4 8 -1 
4 5 -1 6 7 -1 -1 
2 6 3 7 4 8 -1 -1 
1 4 5 2 6 3 7 -1 
-1 -1 -1 
2 4 7 5 8 3 6 9 -1 
-1
1 2 6 3 7 4 8 -1 -1 
1 3 6 4 7 2 5 8 -1 
-1
-1
1 3 5 6 2 4 7 -1 
3 4 -1 5 6 -1 7 8 -1 
4 5 -1 6 7 -1...

result:

wrong answer Integer element p[3] equals to -1, violates the range [1, 8]

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Wrong Answer

Test #25:

score: 0
Wrong Answer
time: 0ms
memory: 4480kb

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:

1 2 -1 3 4 -1 5 6 -1 7 8 -1 9 10 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

result:

wrong answer Integer element p[3] equals to -1, violates the range [1, 400]

Subtask #5:

score: 0
Wrong Answer

Test #36:

score: 0
Wrong Answer
time: 0ms
memory: 4356kb

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:

1 2 -1 3 4 -1 5 6 -1 7 8 -1 9 10 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

result:

wrong answer Integer element p[3] equals to -1, violates the range [1, 400]

Subtask #6:

score: 0
Skipped

Dependency #1:

0%

Subtask #7:

score: 0
Skipped

Dependency #4:

0%

Subtask #8:

score: 0
Skipped

Dependency #5:

0%

Subtask #9:

score: 0
Skipped

Dependency #1:

0%