Submission #780608


Source Code Expand

import java.awt.Point;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.ArrayList;

class Main{
	
	private HashMap<Point,Integer> miti;
	private int n;
	
	public Main(){}
	
	public void run(){
		try{
			Scanner s = new Scanner();
			this.n = s.nextInt();
			int m = s.nextInt();
			int ss = s.nextInt()-1;
			this.miti = new HashMap<>();
			for(int i = 0;i<m;i++){
				s.reset();
				int u = s.nextInt()-1;
				int v = s.nextInt()-1;
				miti.put(new Point(u,v),1);
				miti.put(new Point(v,u),1);
			}
			for(int i = 0;i<=ss;i++){
				if(saiki(i,ss)){
					System.out.println(i+1);
					for(Point point:miti.keySet()){
						if(point.x == i || point.y == i){
							miti.put(point,0);
						}
					}
				}else{
//					System.out.println((i+1)+" is failed");
				}
			}
//			System.out.println();
			
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public boolean saiki(int index,int current){
		if(index == current){return true;}
		if(index<current){
			for(int j = 0;j<current;j++){
				if(miti.containsKey(new Point(current,j))){
				if(miti.get(new Point(current,j))==1){
//					System.out.println("\t"+current+"->"+j);
					if(saiki(index,j))return true;
				}
				}
			}
		}else{
			for(int j = current;j<n;j++){
				if(miti.containsKey(new Point(current,j))){
				if(miti.get(new Point(current,j))==1){
//					System.out.println("\t"+current+"->"+j);
					if(saiki(index,j))return true;		
				}}
			}
		}
		return false;
	}
	
	public static void main(String[] argv){
		Main main = new Main();
		main.run();
	}
	
	private class Scanner{
		private int p;
		private BufferedReader br;
		String regex = " ";
		String[] token;

		public Scanner(){
			br = new BufferedReader(new InputStreamReader(System.in));
			p = -1;
			token = new String[0];
		}
		
		void setRegex(String str){
			this.regex = str;
		}
		
		void reset(){
			p = -1;
			token = new String[0];
		}
		
		String next() throws IOException{
			if(p < 0){
				String line = br.readLine();
				while("".equals(line))line = br.readLine();
				token = line.split(regex,0);
				p = 0;
				return token[p++];
			}else{
				if(p<token.length)return token[p++];
				p = -1;
				return null;
			}
		}
	
		int nextInt() throws NumberFormatException, IOException{
			return Integer.parseInt(next());
		}
		
		long nextLong() throws NumberFormatException, IOException{
			return Long.parseLong(next());
		
		}
		
		double nextDouble() throws NumberFormatException, IOException{
			return Double.parseDouble(next());
		}
		
		String nextString() throws NumberFormatException, IOException{
			return next();	
		}		
	}
}

Submission Info

Submission Time
Task B - 駐車場
User shopon1201
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 2822 Byte
Status WA
Exec Time 2113 ms
Memory 65052 KiB

Judge Result

Set Name Sample Subtask0 All
Score / Max Score 0 / 0 0 / 40 0 / 60
Status
AC × 3
AC × 5
WA × 7
TLE × 1
AC × 2
WA × 7
TLE × 11
Set Name Test Cases
Sample sample0.txt, sample1.txt, sample2.txt
Subtask0 subtask0_0.txt, subtask0_1.txt, subtask0_2.txt, subtask0_3.txt, subtask0_4.txt, subtask0_5.txt, subtask0_6.txt, subtask0_7.txt, subtask0_8.txt, subtask0_9.txt, sample0.txt, sample1.txt, sample2.txt
All subtask0_0.txt, subtask0_1.txt, subtask0_2.txt, subtask0_3.txt, subtask0_4.txt, subtask0_5.txt, subtask0_6.txt, subtask0_7.txt, subtask0_8.txt, subtask0_9.txt, subtask1_0.txt, subtask1_1.txt, subtask1_2.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt
Case Name Status Exec Time Memory
sample0.txt AC 153 ms 8016 KiB
sample1.txt AC 165 ms 8144 KiB
sample2.txt AC 161 ms 8020 KiB
subtask0_0.txt TLE 2108 ms 19324 KiB
subtask0_1.txt WA 381 ms 19436 KiB
subtask0_2.txt WA 389 ms 18616 KiB
subtask0_3.txt WA 317 ms 17220 KiB
subtask0_4.txt WA 281 ms 18316 KiB
subtask0_5.txt WA 302 ms 19596 KiB
subtask0_6.txt WA 481 ms 26276 KiB
subtask0_7.txt AC 561 ms 23116 KiB
subtask0_8.txt WA 281 ms 18896 KiB
subtask0_9.txt AC 613 ms 26624 KiB
subtask1_0.txt TLE 2112 ms 63668 KiB
subtask1_1.txt TLE 2112 ms 64668 KiB
subtask1_2.txt TLE 2113 ms 64068 KiB
subtask1_3.txt TLE 2112 ms 64532 KiB
subtask1_4.txt TLE 2112 ms 64936 KiB
subtask1_5.txt TLE 2112 ms 65052 KiB
subtask1_6.txt TLE 2112 ms 64772 KiB
subtask1_7.txt TLE 2112 ms 60892 KiB
subtask1_8.txt TLE 2111 ms 54960 KiB
subtask1_9.txt TLE 2108 ms 60440 KiB