QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#564774 | #9284. Christmas Children Circle | ucup-team3161# | TL | 165ms | 127816kb | C++17 | 3.0kb | 2024-09-15 14:26:19 | 2024-09-15 14:26:19 |
Judging History
answer
// what is matter? never mind.
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
//#define int long long
//#define ull unsigned long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
#define mod 1000000007
struct modint{
unsigned int x;
modint(int o=0){x=o;}
modint &operator = (int o){return x=o,*this;}
modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
modint &operator -=(modint o){return x=x<o.x?x-o.x+mod:x-o.x,*this;}
modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
modint &operator ^=(int b){
modint a=*this,c=1;
for(;b;b>>=1,a*=a)if(b&1)c*=a;
return x=c.x,*this;
}
modint &operator /=(modint o){return *this *=o^=mod-2;}
friend modint operator +(modint a,modint b){return a+=b;}
friend modint operator -(modint a,modint b){return a-=b;}
friend modint operator *(modint a,modint b){return a*=b;}
friend modint operator /(modint a,modint b){return a/=b;}
friend modint operator ^(modint a,int b){return a^=b;}
friend bool operator ==(modint a,modint b){return a.x==b.x;}
friend bool operator !=(modint a,modint b){return a.x!=b.x;}
bool operator ! () {return !x;}
modint operator - () {return x?mod-x:0;}
bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}
vector<modint> fac,ifac,iv;
inline void initC(int n)
{
if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
int m=iv.size(); ++n;
if(m>=n)return;
iv.resize(n),fac.resize(n),ifac.resize(n);
For(i,m,n-1){
iv[i]=iv[mod%i]*(mod-mod/i);
fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
}
}
inline modint C(int n,int m){
if(m<0||n<m)return 0;
return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 2000006
#define inf 0x3f3f3f3f
int n;
set<int> a[maxn];
bool vis[maxn];
int res[maxn],nd[maxn],to[maxn];
signed main()
{
n=read();
For(i,0,n-1){
int k=read();
For(j,1,k) a[i].insert(read());
if(a[i].size()==1) nd[i]=*a[i].begin();
}
to[0]=*a[0].begin();
For(i,1,n-1){
if(a[i].count(to[i-1])) to[i]=to[i-1];
else to[i]=*a[i].begin();
}
int u=0,lst=n-1;
while(u<n){
if(a[u].count(to[lst])){
to[u]=to[lst];
lst=(lst+1)%n,u=(u+1)%n;
}
else break;
}
For(i,0,n-1)cout<<to[i]<<" ";
return 0;
}
/*
2
-8
-4
16
123
4 4
6
3
6 5 1 2 2 3 2 4 2 5 5 6 4 6 1 2 1 3 1 4 2 3 2 4 3 4 5 6 1 2 1 3 1 4 2 5 3 5 4 5
*/
詳細信息
Test #1:
score: 100
Accepted
time: 8ms
memory: 98072kb
input:
3 2 1 4 2 4 3 2 3 1
output:
1 3 3
result:
ok Participant's answer is valid
Test #2:
score: 0
Accepted
time: 12ms
memory: 99960kb
input:
4 1 2 1 3 1 5 1 2
output:
2 3 5 2
result:
ok Participant's answer is valid
Test #3:
score: 0
Accepted
time: 7ms
memory: 97428kb
input:
3 3 5 3 4 3 3 2 1 3 2 5 1
output:
3 3 1
result:
ok Participant's answer is valid
Test #4:
score: 0
Accepted
time: 16ms
memory: 97448kb
input:
10 10 15 33 96 77 35 59 67 86 48 14 10 77 62 46 78 54 43 81 84 41 94 10 85 13 96 66 51 76 97 69 17 41 10 80 36 16 14 48 56 95 4 2 89 10 22 59 63 41 55 39 64 25 24 47 10 57 12 100 47 22 26 77 28 74 24 10 60 38 32 13 73 57 66 20 29 51 10 95 52 87 86 40 100 74 11 57 19 10 41 85 81 1 80 28 82 11 61 20 1...
output:
14 41 41 2 22 22 13 11 11 17
result:
ok Participant's answer is valid
Test #5:
score: 0
Accepted
time: 21ms
memory: 97788kb
input:
10 10 256 235 455 68 912 951 92 72 45 506 10 788 459 858 234 200 205 592 952 981 433 10 983 527 93 481 920 192 540 131 435 825 10 705 122 204 992 882 386 302 251 167 447 10 91 571 199 84 631 3 612 212 751 973 10 294 307 174 414 532 75 843 967 928 218 10 150 987 360 284 503 680 902 652 826 37 10 610 ...
output:
45 200 93 122 3 75 37 37 2 91
result:
ok Participant's answer is valid
Test #6:
score: 0
Accepted
time: 11ms
memory: 98904kb
input:
100 100 308 381 309 879 394 248 348 872 55 891 779 901 180 966 657 557 918 812 3 7 849 927 543 424 994 802 642 549 155 2 929 947 908 809 319 93 865 263 647 460 37 488 689 83 737 493 924 662 980 380 571 499 956 186 893 548 142 434 336 703 610 961 22 616 759 860 221 342 537 189 837 889 986 370 291 97 ...
output:
3 3 6 1 38 25 6 14 10 2 7 18 30 51 2 3 3 1 10 3 8 16 3 3 15 15 4 4 18 9 35 7 1 5 19 2 2 1 3 10 3 20 24 14 16 3 1 33 1 12 14 16 16 5 4 9 2 8 1 9 19 6 25 20 23 3 41 4 11 13 2 5 16 32 1 10 1 6 7 1 1 5 10 31 3 1 2 2 4 7 16 12 12 1 9 4 3 16 2 3
result:
ok Participant's answer is valid
Test #7:
score: 0
Accepted
time: 56ms
memory: 122264kb
input:
5000 100 671148784 781153534 848639850 244318879 920427959 976787159 662986707 17638884 256078787 940932034 15387769 4277164 669457577 981760450 528396899 953853486 789460571 623739311 666137175 571886662 586564182 65402266 983514575 348179501 926943880 621280777 210157624 589857621 209996932 126799...
output:
1225346 10453619 9323826 1882543 2790906 30619840 3756917 11299864 172834 339945 14145194 4146731 4450967 6603201 30809951 7738254 213922 1908854 10817789 11203829 3442576 9184240 5083545 11234721 9911110 7922349 3063246 16230664 10078691 6609086 1831881 11237487 5321674 16494454 9139632 2593716 202...
result:
ok Participant's answer is valid
Test #8:
score: 0
Accepted
time: 81ms
memory: 127816kb
input:
500000 1 742952893 1 894098557 1 316681304 1 169399596 1 407815175 1 591546816 1 629526487 1 405767078 1 583764255 1 375211436 1 905656564 1 50699406 1 656554721 1 254265551 1 796682967 1 368442317 1 555053666 1 255102479 1 742200093 1 772658913 1 555947624 1 719859491 1 832057943 1 137598300 1 5036...
output:
742952893 894098557 316681304 169399596 407815175 591546816 629526487 405767078 583764255 375211436 905656564 50699406 656554721 254265551 796682967 368442317 555053666 255102479 742200093 772658913 555947624 719859491 832057943 137598300 503661037 42304789 376922249 543143268 889959072 163878086 32...
result:
ok Participant's answer is valid
Test #9:
score: 0
Accepted
time: 165ms
memory: 121080kb
input:
2 250000 442152138 501649759 936373770 29058552 527756596 412071790 172023241 444628322 825636620 433787178 596079227 15316744 523579838 685821859 82734705 149524370 546691322 852742895 446063311 870255039 969869509 749178661 272171528 494909074 965998585 24212670 675848630 317500039 297668742 38577...
output:
8915 14483
result:
ok Participant's answer is valid
Test #10:
score: 0
Accepted
time: 25ms
memory: 102912kb
input:
10000 10 15 9 5 8 12 19 14 20 4 13 10 19 6 8 15 12 4 18 3 16 10 10 18 19 3 4 7 17 13 8 9 14 10 14 15 13 4 19 1 2 11 12 10 10 18 8 4 14 10 2 16 11 19 7 10 19 14 13 4 8 18 6 17 1 10 10 15 20 8 1 5 10 13 2 14 19 10 11 15 4 6 13 17 19 3 1 20 10 14 5 13 19 7 20 8 12 10 3 10 15 19 2 14 3 9 16 6 17 11 10 2...
output:
4 4 4 4 4 4 1 1 3 3 3 3 3 4 3 3 1 1 1 1 1 4 4 4 4 4 4 1 2 4 1 3 1 1 1 1 2 1 2 2 2 2 2 5 5 1 2 2 2 2 2 2 4 3 2 2 3 6 3 4 4 2 1 1 1 4 4 4 3 3 3 3 1 2 2 2 1 2 2 2 2 2 5 1 2 1 1 5 5 5 1 4 3 3 3 1 1 5 5 1 3 3 2 2 2 1 1 2 5 5 5 5 2 1 3 3 1 2 2 1 7 7 7 7 7 7 7 7 1 1 2 2 1 4 2 2 1 1 1 4 4 2 2 1 3 4 1 2 2 3 ...
result:
ok Participant's answer is valid
Test #11:
score: -100
Time Limit Exceeded
input:
707 707 462 205 220 449 157 281 404 661 109 258 228 412 425 156 121 37 66 352 324 159 514 144 18 2 688 525 606 158 150 175 225 100 653 191 495 236 388 544 254 342 203 545 667 127 605 224 644 489 613 446 499 457 547 276 640 50 570 672 556 647 515 524 410 40 302 52 4 255 261 137 365 656 380 443 206 97...