QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#576743#9308. World CupfuchenWA 51ms39596kbJava82.9kb2024-09-19 21:50:312024-09-19 21:50:35

Judging History

你现在查看的是最新测评结果

  • [2024-09-19 21:50:35]
  • 评测
  • 测评结果:WA
  • 用时:51ms
  • 内存:39596kb
  • [2024-09-19 21:50:31]
  • 提交

answer

import java.util.Scanner;

public class Main{
    static  int a[][]=new int[9][5]; //32
    static  int b[][]=new int[9][3]; //16
    static  int c[]=new int[10]; //8
    static  int d[]=new int[5];//4
    static  int f[]=new int[3];//2
    public  static  int get1(int l,int r){
        int res=0;
        for(int i=1;i<=4;i++){
            if(i==r) continue;
            if(a[l][r]>a[l][i]) res++;
        }
        return  res;
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t-->0){
            for(int i=1;i<=8;i++){
                for(int j=1;j<=4;j++){
                    a[i][j]=sc.nextInt();
                }
            }
            int cnt[][]=new int[9][5];
            for(int i=1;i<=8;i++){
                for(int j=1;j<=4;j++){
                    cnt[i][j]=get1(i,j);
                }
            }
            //循环赛
            for(int i=1;i<=8;i++){
                int idx1=1,idx2=1;
                for(int j=1;j<=4;j++){
                  if(cnt[i][j]>cnt[i][idx1]){
                      idx2=idx1;
                      idx1=j;
                  }else if(cnt[i][j]==cnt[i][idx1]){
                      idx2=j;
                  }else if(cnt[i][j]>cnt[i][idx2]){
                      idx2=j;
                  }
                }
                b[i][1]=idx1;
                b[i][2]=idx2;
            }
            if(b[1][1]!=1 && b[1][2]!=1) {
                System.out.println(32);
                return;
            }
            //淘汰赛
            for(int i=1;i<=7;i++){
                if(a[i][b[i][1]]>a[i+1][b[i+1][2]]){
                    c[i]=a[i][b[i][1]];
                }else{
                    c[i]=a[i+1][b[i+1][2]];
                }
            }
            if(a[8][b[8][1]]>a[8][b[1][2]]){
                c[8]=a[8][b[8][1]];
            }else{
                c[8]=a[8][b[1][2]];
            }
            if(c[1]!=a[1][1] && c[8]!=a[1][1]){
                System.out.println(16);
                return;
            }
            int count=0;
            for(int i=2;i<=8;i+=2){
                d[++count]=Math.max(c[i-1],c[i]);
            }
            boolean flag=false;
            for(int i=1;i<=count;i++){
                if(d[i]==a[1][1]){
                    flag=true;
                    break;
                }
            }
            if(!flag){
                System.out.println(8);
                return;
            }
            f[1]=Math.max(d[1],d[2]);
            f[2]=Math.max(d[3],d[4]);
            if(f[1]!=a[1][1] && f[2]!=a[1][1]){
                System.out.println(4);
                return;
            }
            int res=Math.max(f[1],f[2]);
            if(res==a[1][1]){
                System.out.println(1);
            }else{
                System.out.println(2);
            }
        }
    }
}

详细

Test #1:

score: 100
Accepted
time: 49ms
memory: 39596kb

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: 51ms
memory: 38448kb

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

result:

wrong answer Answer contains longer sequence [length = 32], but output contains 1 elements