QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#568813 | #9308. World Cup | 01_Dreamer | WA | 4ms | 3792kb | C++17 | 3.5kb | 2024-09-16 18:40:44 | 2024-09-16 18:40: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=2e9;
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3572kb
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: -100
Wrong Answer
time: 4ms
memory: 3792kb
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 2000000000 2000000000 2000000000 2000000000 2000000000 2000000000 2000000000 16 16 16 8 8 8 8 8 4 4 4 4 4 4 4 4 4 4 2 2 2 2 1
result:
wrong answer 3rd numbers differ - expected: '16', found: '2000000000'