結果
| 問題 |
No.3012 岩井星人グラフ
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2025-01-28 09:00:28 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 431 ms / 2,000 ms |
| コード長 | 1,803 bytes |
| コンパイル時間 | 2,945 ms |
| コンパイル使用メモリ | 87,824 KB |
| 実行使用メモリ | 81,780 KB |
| 最終ジャッジ日時 | 2025-01-28 09:00:47 |
| 合計ジャッジ時間 | 15,507 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 23 |
ソースコード
import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner();
int n = sc.nextInt();
int m = sc.nextInt();
List<Path> ans = new ArrayList<>();
for (int i = 0; i < n; i++) {
ans.add(new Path(i + 1, (i + 1) % n + 1));
for (int j = 1; j < m; j++) {
ans.add(new Path(i + (j - 1) * n + 1, i + j * n + 1));
}
}
System.out.println(n * m + " " + (n * m));
System.out.println(ans.stream().map(x -> x.toString()).collect(Collectors.joining("\n")));
}
static class Path {
int left;
int right;
public Path(int left, int right) {
this.left = left;
this.right = right;
}
public String toString() {
return left + " " + right;
}
}
}
class Scanner {
BufferedReader br;
StringTokenizer st = new StringTokenizer("");
public Scanner() {
try {
br = new BufferedReader(new InputStreamReader(System.in));
} catch (Exception e) {
}
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
public double nextDouble() {
return Double.parseDouble(next());
}
public String next() {
try {
while (!st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
} catch (Exception e) {
e.printStackTrace();
} finally {
return st.nextToken();
}
}
}
tenten