Submission #272310

#TimeUsernameProblemLanguageResultExecution timeMemory
272310MrTEKRestore Array (RMI19_restore)C++14
Compilation error
0 ms0 KiB
import java.util.*; public class restore{ public static class Edge { public int u,v,cost; public Edge(int _u,int _v,int _cost) { u = _u; v = _v; cost = _cost; } } static int n,m; static int[] pre; static ArrayList <Edge> edges; static boolean SP() { pre[0] = 0; for (int i = 1 ; i <= n ; i++) pre[i] = 1000000000; for (int i = 0 ; i < n ; i++) { for (Edge j : edges) { int val = pre[j.u] + j.cost; pre[j.v] = Math.min(val,pre[j.v]); } } for (Edge j : edges) { int val = pre[j.u] + j.cost; if (pre[j.v] > val) return false; } return true; } public static void main(String[] args) { Scanner scan = new Scanner(System.in); n = scan.nextInt(); m = scan.nextInt(); edges = new ArrayList<Edge>(); pre = new int[n+1]; for (int i = 1 ; i <= n ; i++) { edges.add(new Edge(i-1,i,1)); edges.add(new Edge(i,i-1,0)); } while((m--) != 0) { int l = scan.nextInt(); int r = scan.nextInt(); int k = scan.nextInt(); int val = scan.nextInt(); l++; r++; if (val == 0) edges.add(new Edge(l-1,r,r-l-k+1)); else edges.add(new Edge(r,l-1,-(r-l-k+2))); } if (SP() == false) System.out.println("-1"); else { for (int i = n ; i >= 1 ; i--) pre[i] -= pre[i - 1]; for (int i = 1 ; i <= n ; i++) System.out.printf("%d ",pre[i]); System.out.println(); } } }

Compilation message (stderr)

restore.cpp:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
restore.cpp:2:1: error: expected unqualified-id before 'public'
    2 | public class restore{
      | ^~~~~~