結果
| 問題 |
No.630 門松グラフ
|
| コンテスト | |
| ユーザー |
夕叢霧香(ゆうむらきりか)
|
| 提出日時 | 2018-01-05 21:38:32 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 407 ms / 1,500 ms |
| コード長 | 2,420 bytes |
| コンパイル時間 | 2,681 ms |
| コンパイル使用メモリ | 79,444 KB |
| 実行使用メモリ | 46,428 KB |
| 最終ジャッジ日時 | 2024-12-23 06:27:35 |
| 合計ジャッジ時間 | 11,450 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
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;
}
}
}
夕叢霧香(ゆうむらきりか)