제출 #651973

#제출 시각아이디문제언어결과실행 시간메모리
651973ziduoPotemkin cycle (CEOI15_indcyc)Java
컴파일 에러
0 ms0 KiB
import java.io.*; import java.util.*; public class Main { public static void main(String[] args)throws IOException { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); int r = Integer.parseInt(st.nextToken()); ArrayList<Integer>[] edges = new ArrayList[n]; for(int i=0; i<n; i++)edges[i] = new ArrayList<>(); for(int i=0; i<r; i++) { st = new StringTokenizer(br.readLine()); int a = Integer.parseInt(st.nextToken())-1; int b = Integer.parseInt(st.nextToken())-1; edges[a].add(b); edges[b].add(a); } boolean[][] same = new boolean[n][n]; for(int i=0; i<n; i++)for(int j=0; j<edges[i].size(); j++)same[i][edges[i].get(j)]=true; LinkedList<Integer> list = new LinkedList<>(); for(int i=0; i<n; i++)for(int j: edges[i]) { int[] dist = new int[n]; Arrays.fill(dist, -1); dist[j]=i; for(int tar: edges[j])if(!same[tar][i]&&tar!=i) { list.add(tar); dist[tar]=j; } while(!list.isEmpty()) { int s= list.size(); for(int k=0; k<s; k++) { int num = list.removeFirst(); for(int tar: edges[num]) { if(dist[tar]!=-1||(same[j][tar]&&tar!=i))continue; dist[tar] = num; if(tar==i)break; list.add(tar); } if(dist[i]!=-1)break; } if(dist[i]!=-1)break; } list.clear(); if(dist[i]!=-1) { int cur = dist[i]; while(cur!=i) { out.write((cur+1)+" "); cur = dist[cur]; } out.write((i+1)+""); out.flush(); out.close(); return; } } out.write("no"); out.flush(); out.close(); } }

컴파일 시 표준 에러 (stderr) 메시지

indcyc.java:3: error: class Main is public, should be declared in a file named Main.java
public class Main {
       ^
Note: indcyc.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error