QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#22401 | #2351. Lost in Transfer | DaBenZhongXiaSongKuaiDi# | 0 | 0ms | 0kb | C++20 | 2.5kb | 2022-03-09 17:10:20 | 2023-01-17 09:35:19 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define mod 1000000009
#define int long long
using namespace std;
inline int read()
{
int n=0,f=1,ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
n=n*10+ch-'0';
ch=getchar();
}
return n*f;
}
int a[10005],b[10005];
char s[200005];
int dy[1000005];
int cnt;
bool vis[7];
int pos[10005],rk[7];
void dfs(int x,int now)
{
if(x==7)
{
dy[now]=cnt;
cnt++;
//printf("%d %d\n",now,cnt);
return;
}
for(int i=1;i<=6;i++)
{
if(vis[i])continue;
vis[i]=true;
dfs(x+1,now*10+i);
vis[i]=false;
}
}
int tans[1005];
bool bi(int x,int y)
{
return b[x]<b[y];
}
int n;
int check(int x)
{
for(int i=0;i<512;i++)tans[i]=0;
for(int i=1;i<=n;i++)
{
if(i==x)continue;
if(i<x)b[i]=a[i];
else b[i-1]=a[i];
}
for(int i=1;i<=n-5;i++)
{
if(x<=n&&i==n-5)break;
for(int j=i;j<=i+5;j++)pos[j]=j;
sort(pos+i,pos+i+6,bi);
for(int j=i;j<=i+5;j++)rk[pos[j]-i+1]=j-i+1;
int gre=0;
for(int j=1;j<=6;j++)gre=gre*10+rk[j];
tans[dy[gre]]++;
}
int maxn=0,mpos=0;
for(int i=0;i<=511;i++)
{
if(tans[i]>maxn)
{
maxn=tans[i];
mpos=i;
}
}
return mpos;
}
signed main()
{
dfs(1,0);
int t,yh;
scanf("%s",s+1);
if(s[1]=='t')
{
t=read();
for(int greg=1;greg<=t;greg++)
{
n=read();
yh=0;
for(int i=1;i<=n;i++)a[i]=i,yh^=a[i];
random_shuffle(a+1,a+n+1);
//printf("%d\n",yh);
for(int i=1;i<=n;i+=6)
{
if(i+5>n)break;
sort(a+i,a+i+6);
for(int j=1;j<=yh;j++)
{
next_permutation(a+i,a+i+6);
}
}
//printf("orz\n");
/*if(n>60)
{
for(int i=1;i<=n;i++)printf("%d ",a[i]);
printf("\n");
continue;
}*/
while(1)
{
//printf("orz\n");
bool flag=true;
for(int i=1;i<=n+1;i++)
{
if(check(i)!=yh)
{
//printf("%d %d %d\n",i,check(i),yh);
flag=false;
break;
}
}
if(flag==true)break;
random_shuffle(a+1,a+n+1);
for(int i=1;i<=n;i+=6)
{
if(i+5>n)break;
sort(a+i,a+i+6);
for(int j=1;j<=yh;j++)
{
next_permutation(a+i,a+i+6);
}
}
}
for(int i=1;i<=n;i++)printf("%d ",a[i]);
printf("\n");
}
}
else
{
t=read();
for(int greg=1;greg<=t;greg++)
{
n=read();
yh=0;
for(int i=1;i<=n;i++)a[i]=read(),yh^=a[i];
//printf("%d\n",yh);
int gre=(yh^check(n+1));
if(gre!=0)printf("%d ",gre);
for(int i=1;i<=n;i++)printf("%d ",a[i]);
printf("\n");
}
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
input:
transmit 2 20 97 388 459 467 32 99 98 296 403 325 330 271 87 333 378 267 405 58 426 374 20 125 481 451 150 495 136 444 192 118 26 68 281 120 61 494 339 86 292 100 32
output:
5 11 17 15 12 16 2 4 18 8 7 10 1 3 20 13 6 19 14 9 23 26 62 82 90 83 17 36 39 40 63 54 15 21 41 56 61 57 27 35 47 51 69 66 29 34 50 73 80 79 1 3 9 25 46 42 7 14 22 44 87 86 6 33 53 58 77 60 13 19 31 70 76 74 8 10 30 52 96 72 4 12 20 37 59 45 2 32 49 84 95 89 11 18 81 91 97 92 24 38 67 71 85 78 5 16...
input:
output:
result:
wrong answer The sequence your program outputs on the first run is invalid. (test case 1)