QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#470504 | #6399. Classic: Classical Problem | UESTC_xxx# | WA | 0ms | 4068kb | C++14 | 1.3kb | 2024-07-10 14:37:27 | 2024-07-10 14:37:27 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL maxn = 1e9+10,N=3*1e5+120,g=239,mod=1e9 + 7,cmod=998244353,INF=1e16;
LL n,m,k,t,p;
LL pow(LL k,LL x,LL p)
{
LL re=1;
while(k)
{
if(k&1) re=(re*x)%p;
x=(x*x)%p;
k>>=1;
}
return re;
}
LL a[N];
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%lld%lld",&n,&p);
queue<int> q[2],qmid;
int mid;
for(int i=0;i<p;i++) a[i]=0;
for(int i=1;i<=n;i++)
{
scanf("%d",&mid);
a[mid]=1;
}
if(n==p)
{
printf("%d %d\n",p-1,p);
for(int i=1;i<p;i++)
{
if(i==1)
printf("%d",i);
else
printf(" %d",i);
if(i==p-1)
printf("\n");
}
}
else if(a[0]==0)
{
printf("1 1\n0\n");
}else
{
for(int i=0;i<p;i++)
q[0].push(i);
int ff=0;
for(int i=1;i<p;i++)
{
while(!q[(i+1)%2].empty())
{
int x=q[(i+1)%2].front();
q[(i+1)%2].pop();
qmid.push(x);
if(x!=0&&a[i*x]==1)
q[i%2].push(x);
}
if(q[i%2].empty())
{
printf("%d %d\n",qmid.size(),i);
while(!qmid.empty())
{
int x=qmid.front();
qmid.pop();
printf("%d ",x);
}
printf("\n");
break;
}
while(!qmid.empty()) qmid.pop();
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3796kb
input:
3 2 3 0 2 3 5 2 3 4 3 5 0 2 3
output:
1 2 2 1 1 0 2 2 2 3
result:
ok 6 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 4068kb
input:
3 1 2 0 1 2 1 2 2 1 0
output:
2 1 0 1 1 1 0 1 2 1
result:
ok 6 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
7 1 3 0 1 3 1 2 3 1 0 1 3 2 2 3 2 0 2 3 1 2 3 3 0 1 2
output:
3 1 0 1 2 1 1 0 1 2 1 1 1 0 1 2 2 1 1 0 2 3 1 2
result:
ok 14 lines
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3772kb
input:
31 1 5 0 1 5 1 2 5 1 0 1 5 2 2 5 0 2 2 5 2 1 3 5 1 0 2 1 5 3 2 5 0 3 2 5 1 3 3 5 0 1 3 2 5 3 2 3 5 0 2 3 3 5 2 1 3 4 5 2 0 1 3 1 5 4 2 5 4 0 2 5 1 4 3 5 1 4 0 2 5 2 4 3 5 2 4 0 3 5 4 2 1 4 5 1 0 4 2 2 5 4 3 3 5 0 4 3 3 5 3 1 4 4 5 1 4 3 0 3 5 4 3 2 4 5 2 4 0 3 4 5 2 1 4 3 5 5 1 3 0 2 4
output:
5 1 0 1 2 3 4 1 1 0 1 2 1 1 1 0 1 2 2 1 1 0 1 3 1 1 1 0 1 2 3 1 1 0 2 2 1 3 1 1 0 2 2 2 3 1 1 0 1 4 1 1 1 0 1 2 4 1 1 0 2 2 1 4 1 1 0 1 3 2 1 1 0 2 3 1 2 1 1 0 2 2 3 4 1 1 0 3 2 1 3 4 1 1 0 1 3 2 1 1 0 4 5 1 2 3 4
result:
wrong answer 10th lines differ - expected: '3', found: '2 '