Submission #58767


Source Code Expand

import java.util.Scanner;

public class Main {

	static boolean[] visited;
	static int n;
	static boolean[][] edge;
	static boolean bCycle = false;

	public static void main(String[] args) {
		doIt();
	}
	//for N = 100, M = 100
	static void doIt(){
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int m = sc.nextInt();
		edge = new boolean[n][n];
		for(int i = 0; i < n; i++) edge[i][i] = true;
		for(int i = 0; i < m; i++){
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			edge[a][b] = edge[b][a] = !edge[a][b];
			visited = new boolean[n];
			bCycle = false;
			for(int j = 0; j < n; j++) departure(j);
			System.out.println(bCycle? "no" : "yes");
		}



	}
	static void departure(int s){
		if(visited[s] == false){
			visited[s] = true;
			for(int i = 0; i < n; i++){
				if(edge[s][i] == false) search(s, i);
			}
		}
	}
	static void search(int from, int to){
		if(visited[to]){ bCycle = true; return;}
		visited[to] = true;
		for(int i = 0; i < n; i++){
			if(i != from && edge[to][i] == false) search(to, i);
		}
	}

}

Submission Info

Submission Time
Task C - 森ですか?
User mkiken
Language Java (OpenJDK 1.7.0)
Score 50
Code Size 1099 Byte
Status MLE
Exec Time 2094 ms
Memory 268340 KB

Judge Result

Set Name Easy All
Score / Max Score 50 / 50 0 / 50
Status
AC × 37
AC × 37
TLE × 40
MLE × 2
Set Name Test Cases
Easy easy_01_00.txt, easy_01_01.txt, easy_01_02.txt, easy_01_03.txt, easy_01_04.txt, easy_02_00.txt, easy_02_01.txt, easy_02_02.txt, easy_02_03.txt, easy_02_04.txt, easy_03_00.txt, easy_03_01.txt, easy_03_02.txt, easy_03_03.txt, easy_03_04.txt, easy_04_00.txt, easy_04_01.txt, easy_04_02.txt, easy_04_03.txt, easy_04_04.txt, easy_05_00.txt, easy_05_01.txt, easy_05_02.txt, easy_05_03.txt, easy_05_04.txt, easy_06_00.txt, easy_06_01.txt, easy_06_02.txt, easy_06_03.txt, easy_06_04.txt, easy_07_00.txt, easy_07_01.txt, easy_07_02.txt, easy_07_03.txt, easy_07_04.txt, easy_08_00.txt, easy_08_01.txt
All easy_01_00.txt, easy_01_01.txt, easy_01_02.txt, easy_01_03.txt, easy_01_04.txt, easy_02_00.txt, easy_02_01.txt, easy_02_02.txt, easy_02_03.txt, easy_02_04.txt, easy_03_00.txt, easy_03_01.txt, easy_03_02.txt, easy_03_03.txt, easy_03_04.txt, easy_04_00.txt, easy_04_01.txt, easy_04_02.txt, easy_04_03.txt, easy_04_04.txt, easy_05_00.txt, easy_05_01.txt, easy_05_02.txt, easy_05_03.txt, easy_05_04.txt, easy_06_00.txt, easy_06_01.txt, easy_06_02.txt, easy_06_03.txt, easy_06_04.txt, easy_07_00.txt, easy_07_01.txt, easy_07_02.txt, easy_07_03.txt, easy_07_04.txt, easy_08_00.txt, easy_08_01.txt, hard_01_00.txt, hard_01_01.txt, hard_01_02.txt, hard_01_03.txt, hard_01_04.txt, hard_02_00.txt, hard_02_01.txt, hard_02_02.txt, hard_02_03.txt, hard_02_04.txt, hard_03_00.txt, hard_03_01.txt, hard_03_02.txt, hard_03_03.txt, hard_03_04.txt, hard_04_00.txt, hard_04_01.txt, hard_04_02.txt, hard_04_03.txt, hard_04_04.txt, hard_05_00.txt, hard_05_01.txt, hard_05_02.txt, hard_05_03.txt, hard_05_04.txt, hard_06_00.txt, hard_06_01.txt, hard_06_02.txt, hard_06_03.txt, hard_06_04.txt, hard_07_00.txt, hard_07_01.txt, hard_07_02.txt, hard_07_03.txt, hard_07_04.txt, hard_08_00.txt, hard_08_01.txt, hard_09_00.txt, hard_09_01.txt, hard_09_02.txt, hard_09_03.txt, hard_09_04.txt
Case Name Status Exec Time Memory
easy_01_00.txt AC 600 ms 22576 KB
easy_01_01.txt AC 540 ms 20656 KB
easy_01_02.txt AC 527 ms 22168 KB
easy_01_03.txt AC 487 ms 22324 KB
easy_01_04.txt AC 486 ms 22308 KB
easy_02_00.txt AC 515 ms 21588 KB
easy_02_01.txt AC 590 ms 21424 KB
easy_02_02.txt AC 511 ms 20652 KB
easy_02_03.txt AC 512 ms 21560 KB
easy_02_04.txt AC 546 ms 21552 KB
easy_03_00.txt AC 480 ms 22316 KB
easy_03_01.txt AC 477 ms 22320 KB
easy_03_02.txt AC 538 ms 20752 KB
easy_03_03.txt AC 567 ms 20656 KB
easy_03_04.txt AC 471 ms 20632 KB
easy_04_00.txt AC 518 ms 22572 KB
easy_04_01.txt AC 480 ms 20492 KB
easy_04_02.txt AC 476 ms 21872 KB
easy_04_03.txt AC 492 ms 22452 KB
easy_04_04.txt AC 538 ms 21296 KB
easy_05_00.txt AC 500 ms 22324 KB
easy_05_01.txt AC 460 ms 20780 KB
easy_05_02.txt AC 522 ms 22048 KB
easy_05_03.txt AC 496 ms 22356 KB
easy_05_04.txt AC 529 ms 22360 KB
easy_06_00.txt AC 570 ms 22068 KB
easy_06_01.txt AC 580 ms 21848 KB
easy_06_02.txt AC 443 ms 20200 KB
easy_06_03.txt AC 519 ms 22756 KB
easy_06_04.txt AC 541 ms 21804 KB
easy_07_00.txt AC 522 ms 22448 KB
easy_07_01.txt AC 491 ms 22324 KB
easy_07_02.txt AC 564 ms 21808 KB
easy_07_03.txt AC 598 ms 22272 KB
easy_07_04.txt AC 463 ms 22324 KB
easy_08_00.txt AC 493 ms 21964 KB
easy_08_01.txt AC 507 ms 22132 KB
hard_01_00.txt TLE 2037 ms 25160 KB
hard_01_01.txt TLE 2036 ms 26380 KB
hard_01_02.txt TLE 2035 ms 25732 KB
hard_01_03.txt TLE 2066 ms 29652 KB
hard_01_04.txt TLE 2037 ms 29772 KB
hard_02_00.txt MLE 1139 ms 268212 KB
hard_02_01.txt TLE 2044 ms 90556 KB
hard_02_02.txt TLE 2044 ms 68872 KB
hard_02_03.txt TLE 2038 ms 50820 KB
hard_02_04.txt MLE 1185 ms 268340 KB
hard_03_00.txt TLE 2036 ms 25728 KB
hard_03_01.txt TLE 2036 ms 29524 KB
hard_03_02.txt TLE 2094 ms 25148 KB
hard_03_03.txt TLE 2039 ms 25440 KB
hard_03_04.txt TLE 2036 ms 25108 KB
hard_04_00.txt TLE 2057 ms 25812 KB
hard_04_01.txt TLE 2034 ms 24196 KB
hard_04_02.txt TLE 2040 ms 30700 KB
hard_04_03.txt TLE 2034 ms 23432 KB
hard_04_04.txt TLE 2065 ms 28760 KB
hard_05_00.txt TLE 2054 ms 24840 KB
hard_05_01.txt TLE 2053 ms 27148 KB
hard_05_02.txt TLE 2048 ms 25528 KB
hard_05_03.txt TLE 2035 ms 25232 KB
hard_05_04.txt TLE 2035 ms 24660 KB
hard_06_00.txt TLE 2043 ms 24832 KB
hard_06_01.txt TLE 2036 ms 23936 KB
hard_06_02.txt TLE 2052 ms 24768 KB
hard_06_03.txt TLE 2035 ms 29228 KB
hard_06_04.txt TLE 2033 ms 30060 KB
hard_07_00.txt TLE 2054 ms 25032 KB
hard_07_01.txt TLE 2034 ms 25340 KB
hard_07_02.txt TLE 2047 ms 26236 KB
hard_07_03.txt TLE 2035 ms 25428 KB
hard_07_04.txt TLE 2035 ms 25448 KB
hard_08_00.txt TLE 2076 ms 24792 KB
hard_08_01.txt TLE 2035 ms 24728 KB
hard_09_00.txt TLE 2035 ms 25716 KB
hard_09_01.txt TLE 2056 ms 26368 KB
hard_09_02.txt TLE 2055 ms 26892 KB
hard_09_03.txt TLE 2039 ms 26512 KB
hard_09_04.txt TLE 2037 ms 27548 KB
sample1.txt AC 462 ms 20152 KB
sample2.txt AC 533 ms 20272 KB