P2327 [SCOI2005]扫雷 题建议加强数据
  • 板块工单反馈版
  • 楼主pipishan
  • 当前回复0
  • 已保存回复0
  • 发布时间2022/5/12 11:10
  • 上次更新2023/10/28 01:38:15
查看原帖
P2327 [SCOI2005]扫雷 题建议加强数据
645290
pipishan楼主2022/5/12 11:10

错误代码

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

/**
 * P2327 [SCOI2005]扫雷
 */
public class Main {
    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static int in() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    static int n;
    static int N = 10010;
    static int[] f = new int[N];
    static int[] a = new int[N];
    public static void main(String[] args) throws IOException {
        n = in();
        for (int i = 1; i <= n; i++) {
            a[i] = in();
        }

        int res = 0;
        f[1] = 0;
        if(check()) {
            ++res;
        }
        f[1] = 1;
        if(check()) {
            ++res;
        }
        System.out.println(res);
    }

    public static boolean check() {
        for (int i = 2; i <= n + 1; i++) {
            f[i] = a[i - 1] - f[i - 1] - f[i - 2];
            if(f[i] < 0) {
                return false;
            }
        }
        return f[n + 1] == 0;
    }
}

这段代码我觉得是错误的,但是却能AC

hack数据:

6
2 2 2 2 2 2

这个样例输出结果是1,实际是0

2022/5/12 11:10
加载中...