Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- public class Main {
- public static void main(String[] args) throws IOException {
- Scanner in = new Scanner(new File("input.txt"));
- PrintWriter pw = new PrintWriter("output.txt");
- int n = in.nextInt();
- int m = in.nextInt();
- int [][] matrix = new int [n][n];
- for (int i = 0; i < m; i++) {
- int a = in.nextInt() - 1;
- int b = in.nextInt() - 1;
- matrix[a][b] = 1;
- matrix[b][a] = 1;
- }
- for (int i = 0; i < n; i++){
- for (int j = i + 1; j < n; j++){
- for (int k = j + 1; k < n; k++){
- if(matrix[i][j] + matrix[j][k] + matrix[k][i] == 2){
- pw.print("NO");
- pw.close();
- return;
- }
- }
- }
- }
- pw.print("YES");
- pw.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement