結果

問題 No.630 門松グラフ
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2018-01-05 21:38:32
言語 Java19
(openjdk 21)
結果
AC  
実行時間 364 ms / 1,500 ms
コード長 2,420 bytes
コンパイル時間 2,264 ms
コンパイル使用メモリ 74,960 KB
実行使用メモリ 58,392 KB
最終ジャッジ日時 2023-08-24 20:35:17
合計ジャッジ時間 10,498 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
54,048 KB
testcase_01 AC 43 ms
49,432 KB
testcase_02 AC 43 ms
49,416 KB
testcase_03 AC 103 ms
54,024 KB
testcase_04 AC 97 ms
53,804 KB
testcase_05 AC 43 ms
49,524 KB
testcase_06 AC 43 ms
49,568 KB
testcase_07 AC 92 ms
52,804 KB
testcase_08 AC 91 ms
53,796 KB
testcase_09 AC 43 ms
49,564 KB
testcase_10 AC 42 ms
49,772 KB
testcase_11 AC 94 ms
54,084 KB
testcase_12 AC 91 ms
53,864 KB
testcase_13 AC 43 ms
49,632 KB
testcase_14 AC 88 ms
53,040 KB
testcase_15 AC 103 ms
53,824 KB
testcase_16 AC 104 ms
53,552 KB
testcase_17 AC 104 ms
54,088 KB
testcase_18 AC 91 ms
53,984 KB
testcase_19 AC 94 ms
54,008 KB
testcase_20 AC 348 ms
57,656 KB
testcase_21 AC 44 ms
49,432 KB
testcase_22 AC 364 ms
58,028 KB
testcase_23 AC 44 ms
49,656 KB
testcase_24 AC 281 ms
58,252 KB
testcase_25 AC 43 ms
49,496 KB
testcase_26 AC 269 ms
58,392 KB
testcase_27 AC 276 ms
57,976 KB
testcase_28 AC 346 ms
57,968 KB
testcase_29 AC 337 ms
57,980 KB
testcase_30 AC 336 ms
57,944 KB
testcase_31 AC 316 ms
57,696 KB
testcase_32 AC 283 ms
57,824 KB
testcase_33 AC 230 ms
57,156 KB
testcase_34 AC 311 ms
57,508 KB
testcase_35 AC 258 ms
57,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        int m=sc.nextInt();
        long nl=n;
        if(m<n-1||(nl/2)*(nl-nl/2)<m){
            out.println("NO");
            out.close();
            return;
        }
        out.println("YES");
        int k=n/2;
        int[]a=new int[n];
        for(int i=0;i<n;++i)a[i]=i+1;
        for(int i=0;i<n;++i)
            out.print(a[i]+(i==n-1?"\n":" "));
        for(int i=0;i<k;++i){
            int x=i;
            int y=k;
            out.println((x+1)+" "+(y+1));
        }
        for(int i=k+1;i<n;++i){
            int x=0;
            int y=i;
            out.println((x+1)+" "+(y+1));
        }
        for(int i=n-1;i<m;++i){
            int j=i-n+1;
            int x=j%(k-1)+1;
            int y=j/(k-1)+k+1;
            out.println((x+1)+" "+(y+1));
        }
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        int[] nextIntArray(int n){
            int[]r=new int[n];
            for(int i=0;i<n;++i)r[i]=nextInt();
            return r;
        }
    }
}
0