Submission #1688489
Source Code Expand
import java.util.ArrayList; import java.util.Scanner; class Main{ static int ans=0; static ArrayList<Integer> list; static ArrayList<ArrayList<Integer>> llist=new ArrayList<ArrayList<Integer>>(); static int n,m; static boolean buf; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n=sc.nextInt();m=sc.nextInt(); for(int i=0;i<n+1;i++){ list=new ArrayList<Integer>(); llist.add(list); } for(int i=0;i<m;i++){ int a=sc.nextInt(); int b=sc.nextInt(); llist.get(a).add(b); llist.get(b).add(a); } boolean[] check=new boolean[n+1]; int cnt=1; buf=search(cnt,check,1); System.out.println(ans); } static boolean search(int cnt,boolean[] check,int ind){ ArrayList<Integer> list=llist.get(ind); check[ind]=true; int cntclone=cnt; boolean[] checklone=check.clone(); if(cntclone==n){ ans++; // System.out.println("ans++"); return true; } for(int i=0;i<list.size();i++){ int next=list.get(i); /* System.out.println("Now="+ind); System.out.println("i="+i+" listsize="+list.size()); for(int z=1;z<n+1;z++){ System.out.print(z+"="+checklone[z]+" "); } System.out.println();*/ if(!checklone[next]){ // System.out.println("TO "+next); buf=search(++cnt,check,next); /* System.out.println("Now="+ind); System.out.println(i+" "+list.size()); for(int z=1;z<n+1;z++){ System.out.print(z+"="+checklone[z]+" "); } System.out.println();*/ }else{ // System.out.println("NotTO "+next); } } return true; } }
Submission Info
Submission Time | |
---|---|
Task | C - One-stroke Path |
User | ri2112 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 1611 Byte |
Status | WA |
Exec Time | 105 ms |
Memory | 25556 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt |
All | sample_01.txt, sample_02.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 105 ms | 21712 KB |
sample_02.txt | AC | 96 ms | 21076 KB |
subtask_1_01.txt | AC | 94 ms | 25556 KB |
subtask_1_02.txt | WA | 94 ms | 20820 KB |
subtask_1_03.txt | WA | 95 ms | 20820 KB |
subtask_1_04.txt | WA | 97 ms | 21844 KB |
subtask_1_05.txt | AC | 97 ms | 19412 KB |
subtask_1_06.txt | AC | 96 ms | 21716 KB |
subtask_1_07.txt | WA | 97 ms | 18900 KB |
subtask_1_08.txt | WA | 96 ms | 21844 KB |
subtask_1_09.txt | WA | 97 ms | 20560 KB |
subtask_1_10.txt | WA | 98 ms | 21844 KB |
subtask_1_11.txt | WA | 98 ms | 20564 KB |
subtask_1_12.txt | WA | 98 ms | 21716 KB |
subtask_1_13.txt | WA | 98 ms | 18772 KB |