QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#326791#5580. Branch ManagertruaCompile Error//C++141.9kb2024-02-14 03:38:322024-02-14 03:38:32

Judging History

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

  • [2024-02-14 03:38:32]
  • 评测
  • [2024-02-14 03:38:32]
  • 提交

answer

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.*;
import java.util.*;

public class branchmanager {
    public static long eulerCount;
    public static long[][] eulerTour;
    public static ArrayList<Integer> adj[];
    public static void main(String[] args) throws IOException{
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(r.readLine());
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());

        eulerTour = new long[n][2];

        adj = new ArrayList[n];
        for (int i=0; i< n; i++) {
            adj[i] = new ArrayList<Integer>();
        }

        for (int i=0; i< n-1; i++) {
            st = new StringTokenizer(r.readLine());
            int a = Integer.parseInt(st.nextToken()) - 1;
            int b = Integer.parseInt(st.nextToken()) - 1;
            adj[a].add(b);
        }

        for (int i=0; i< adj.length; i++) {
            Collections.sort(adj[i]);
        }
        eulerCount = 0;

        dfs(0);
        long eulerBorder = 0; // can't pick any nodes less than the eulerBorder (can only pick bigger nodes)
        for (int i=0; i< m; i++) {
            int node = Integer.parseInt(r.readLine()) - 1;
            if (eulerTour[node][1] < eulerBorder) {
                pw.println(node);
                pw.close();
            }
            else {
                eulerBorder = Math.max(eulerBorder, eulerTour[node][0]);
            }
        }
        pw.println(m);
        pw.close();
    }

    public static void dfs(int node) {
        eulerTour[node][0] = eulerCount;
        for (int i:adj[node]) {
            eulerCount++;
            dfs(i);
        }
        eulerCount++;
        eulerTour[node][1] = eulerCount;
    }
    
}

詳細信息

answer.code:1:1: error: ‘import’ does not name a type
    1 | import java.io.BufferedReader;
      | ^~~~~~
answer.code:1:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’
answer.code:2:1: error: ‘import’ does not name a type
    2 | import java.io.IOException;
      | ^~~~~~
answer.code:2:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’
answer.code:3:1: error: ‘import’ does not name a type
    3 | import java.io.InputStreamReader;
      | ^~~~~~
answer.code:3:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’
answer.code:4:1: error: ‘import’ does not name a type
    4 | import java.io.*;
      | ^~~~~~
answer.code:4:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’
answer.code:5:1: error: ‘import’ does not name a type
    5 | import java.util.*;
      | ^~~~~~
answer.code:5:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’
answer.code:7:1: error: expected unqualified-id before ‘public’
    7 | public class branchmanager {
      | ^~~~~~