# Codeforces Round 860 (Div. 2)题解

1 2 3

1 2 3

#include <bits/stdc++.h>

using namespace std;

const int N = 50050;

int q[N];

int ans[N];

int flag;

int big = -55;

int small = 999999999;

int hk;
int cnt;
int main(){

int t;
cin >> t;

while(t --){

memset(q,-1,sizeof q);

int t1;

cin >> t1;

int temp = t1;

while(t1 --){

flag ++;

int n;

cin >> n;

for(int i = 1;i <= n;i ++){

int x;

cin >> x;

q[x] = flag;

}
}
int flag1 = 0;
int flag2 = 0;
while(temp --){
flag1 ++;
for(int i = 1 ;i <= 50010;i ++){

if(q[i] == flag1){
//cout << i << " ";
ans[cnt ++] = i;
flag2 = 1;
goto lz;
}
}
if(flag2 == 0) {
cout << "-1" << endl;
hk = 1;
goto hkn;
}

lz:;

flag2 = 0;
}
hkn:;
if(hk == 0){
for(int i = 0;ans[i] != 0;i ++){
cout << ans[i] << " ";
}
cout << endl;
}
cnt = 0;
memset(ans,0,sizeof ans);
hk = 0;
flag1 = 0;
flag2 = 0;
flag = 0;

memset(q,-1,sizeof q);

}

return 0;

}

• 0
点赞
• 0
收藏
觉得还不错? 一键收藏
• 打赏
• 0
评论
03-27 633
03-28 383
03-28 184
06-25 469
06-15 319
05-06 1017
04-18 649
05-01 278
05-06 649

codeforces1

¥1 ¥2 ¥4 ¥6 ¥10 ¥20

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、付费专栏及课程。