QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#568826 | #9308. World Cup | 01_Dreamer | AC ✓ | 467ms | 3940kb | C++17 | 3.5kb | 2024-09-16 18:43:44 | 2024-09-16 18:43:45 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
const int N=10;
struct Node
{
int up,down,china;
//up 1 china 0 down -1;
int get_1() const
{
if(up) return 1;
if(china) return 0;
return -1;
}
int get_2() const
{
if(up>=2) return 1;
if(up==1&&china) return 0;
return -1;
}
int get_3() const
{
if(up>=3) return 1;
if(up==2&&china) return 0;
return -1;
}
}con[N];
int res=32;
void dfs(int c,int up,int down)
{
if(c==8)
{
//After 32
for(int i=0;i<8;i++)
{
int T=2;
while(T--)
{
int t=con[i].get_3();
if(t==1) con[i].up--;
else if(t==-1) con[i].down--;
}
}
//After 16
if(con[0].get_1()==0)
{
if(con[1].get_2()==1)
{
res=min(res,16);
return;
}
}
else if(con[0].get_2()==0)
{
if(con[1].get_1()==1)
{
res=min(res,16);
return;
}
}
vector<int>v8;
for(int i=0;i<=6;i+=2)
{
int fi=con[i].get_1();
int se=con[i+1].get_2();
v8.push_back(max(fi,se));
}
for(int i=0;i<=6;i+=2)
{
int fi=con[i+1].get_1();
int se=con[i].get_2();
v8.push_back(max(fi,se));
}
//After 8
bool flag=true;
vector<int>v4;
for(int i=0;i<=6;i+=2)
{
int a=v8[i],b=v8[i+1];
v4.push_back(max(a,b));
if(max(a,b)==0) flag=false;
}
if(flag)
{
res=min(res,8);
return;
}
//After 4
flag=true;
vector<int>v2;
for(int i=0;i<=2;i+=2)
{
int a=v4[i],b=v4[i+1];
v2.push_back(max(a,b));
if(max(a,b)==0) flag=false;
}
if(flag)
{
res=min(res,4);
return;
}
//After 2
if(max(v2[0],v2[1])!=0)
{
res=min(res,2);
return;
}
else
{
res=min(res,1);
return;
}
return;
}
if(c==0)
{
if(up>=1&&down>=2)
{
con[c]={1,2,1};
dfs(c+1,up-1,down-2);
}
if(up>=0&&down>=3)
{
con[c]={0,3,1};
dfs(c+1,up,down-3);
}
}
else
{
for(int i=0;i<=4;i++)
if(up>=i&&down>=4-i)
{
con[c]={i,4-i,0};
dfs(c+1,up-i,down-(4-i));
}
}
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
res=2e9;
memset(con,0,sizeof con);
int up=0,down=0;
int c;
int x;
for(int i=0;i<32;i++)
{
scanf("%d",&x);
if(!i) c=x;
else
{
if(x>c) up++;
else if(x<c) down++;
}
}
if(up==0) puts("1");
else if(down<2) puts("32");
else
{
dfs(0,up,down);
printf("%d\n",res);
}
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3940kb
input:
1 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 13ms
memory: 3800kb
input:
32 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 2 1 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 3 1 2 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 4 1 2 3 5 6 7 8 9 10 11 12 13 14 15 ...
output:
32 32 16 16 16 16 8 8 8 8 8 8 8 4 4 4 4 4 4 4 4 4 4 4 4 4 4 2 2 2 2 1
result:
ok 32 numbers
Test #3:
score: 0
Accepted
time: 467ms
memory: 3752kb
input:
1000 158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202 971407775 628894325 731963982 822804784 450968417 430302156 982631932 161735902 880895728 923078537 707723857 189330739 910286918 802329211 404539679 303238506 317063340 492686568 773361868 125660...
output:
16 4 1 4 1 4 4 2 4 2 4 32 4 2 4 4 8 4 32 1 4 4 2 4 2 16 2 8 4 8 8 1 2 4 8 4 16 4 4 2 4 4 2 16 8 4 2 16 4 8 8 4 4 4 4 16 16 2 1 4 4 8 1 4 4 2 4 8 16 4 4 8 4 32 32 8 8 8 1 4 4 4 4 4 32 8 4 4 8 32 4 4 16 2 8 32 16 8 8 4 1 4 4 16 32 4 4 4 4 4 8 4 4 8 4 4 4 8 16 4 4 8 2 4 4 16 2 8 16 4 4 16 2 32 8 16 4 3...
result:
ok 1000 numbers
Extra Test:
score: 0
Extra Test Passed