用户输出
11
1 -5 1 -5 1 9 1 -5 1 -5 1
Special Judge 信息
Accepted | Correct. answer = 11
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#25414 | #1145. ddd 和渡渡鸟 | Wrong Answer | 13 | 7228 ms | 218344 K | Java / 2.0 K | yukino | 2020-05-01 1:03:58 |
import java.util.*;
public class Main {
static int a;
static int b;
static int N = 1000005;
static int[] h = new int[N];
static int[] e = new int[N * 2];
static int[] ne = new int[N * 2];
static int idx = 0;
static int[] degree = new int[N];
static int[] arr = new int[N];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
a = sc.nextInt();
b = sc.nextInt();
int l = 1, r = 1000000;
while (l < r) {
int mid = l + r + 1 >> 1;
if (work(mid).size() != 0) {
l = mid;
} else {
r = mid - 1;
}
}
System.out.println(l);
ArrayList<Integer> integers = work(l);
for (Integer a : integers) {
System.out.print(a + " ");
}
}
static ArrayList<Integer> work(int n) {
ArrayList<Integer> list = new ArrayList<Integer>();
Queue<Integer> q = new LinkedList<Integer>();
Arrays.fill(h, -1);
Arrays.fill(degree, 0);
for (int i = 1; i <= n; i++) {
if (i - a >= 0) {
add(i - a, i);
degree[i]++;
}
if (i - b >= 0) {
add(i, i - b);
degree[i - b]++;
}
}
for (int i = 0; i <= n; i++) {
if (degree[i] == 0) {
q.add(i);
}
}
int cnt = 0;
while (q.size() != 0) {
int t = q.poll();
arr[t] = ++cnt;
for (int i = h[t]; i != -1; i = ne[i]) {
int c = e[i];
degree[c]--;
if (degree[c] == 0) {
q.add(c);
}
}
}
if (cnt != n + 1) {
return list;
}
for (int i = 1; i <= n; i++) {
list.add(arr[i] - arr[i - 1]);
}
return list;
}
static void add(int x, int y) {
e[idx] = y;
ne[idx] = h[x];
h[x] = idx++;
}
}
用户输出
11
1 -5 1 -5 1 9 1 -5 1 -5 1
Special Judge 信息
Accepted | Correct. answer = 11
系统信息
Exited with return code 0
419
36 36 36 36 36 36 36 36 36 36 -385 36 36 36 36 36 36 36 36 36 36 36 -385 36 36 36 36 36 36 36 36
<1231 bytes omitted>
用户输出
419
36 36 36 36 36 36 36 36 36 36 -385 36 36 36 36 36 36 36 36 36 36 36 -385 36 36 36 36 36 36 36 36 36 36 36 -385 36 36 36 36 3
<1203 bytes omitted>
Special Judge 信息
Accepted | Correct. answer = 419
系统信息
Exited with return code 0
11223
3929 -7296 3929 3929 -7296 3929 3929 -7296 3929 3929 -7296 3929 3929 -7296 3929 3929 -7296 392
<59949 bytes omitted>
标准错误流
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2000010
at Main.add(Main.java:89)
at Main.work(Main.java:49)
at Main.main(Main.java:23)
Special Judge 信息
Presentation Error | Unexpected end of file - int32 expected
系统信息
Exited with return code 1
174689
1 1 1 1 1 1 1 1 -46349 1 1 1 1 1 1 1 1 -46349 1 1 1 1 1 1 1 1 128350 1 1 1 1 1 1 1 1 -46349 1
<446330 bytes omitted>
标准错误流
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2000010
at Main.add(Main.java:89)
at Main.work(Main.java:49)
at Main.main(Main.java:23)
Special Judge 信息
Presentation Error | Unexpected end of file - int32 expected
系统信息
Exited with return code 1
188827
1 -51075 1 -51075 1 137755 1 -51075 1 -51075 1 -51075 1 137755 1 -51075 1 -51075 1 -51075 1 1
<849626 bytes omitted>
标准错误流
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2000010
at Main.add(Main.java:89)
at Main.work(Main.java:49)
at Main.main(Main.java:23)
Special Judge 信息
Presentation Error | Unexpected end of file - int32 expected
系统信息
Exited with return code 1
210661
1 -33215 1 -33215 1 -33215 1 -33215 1 -33215 1 177449 1 -33215 1 -33215 1 -33215 1 -33215 1 -
<947879 bytes omitted>
标准错误流
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2000010
at Main.add(Main.java:89)
at Main.work(Main.java:49)
at Main.main(Main.java:23)
Special Judge 信息
Presentation Error | Unexpected end of file - int32 expected
系统信息
Exited with return code 1
366169
1 1 1 1 1 1 -102157 1 1 1 1 1 1 -102157 1 1 1 1 1 1 264020 1 1 1 1 1 1 -102157 1 1 1 1 1 1 -1
<1031507 bytes omitted>
标准错误流
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2000010
at Main.add(Main.java:89)
at Main.work(Main.java:49)
at Main.main(Main.java:23)
Special Judge 信息
Presentation Error | Unexpected end of file - int32 expected
系统信息
Exited with return code 1
399999
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
<799921 bytes omitted>
标准错误流
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2000010
at Main.add(Main.java:89)
at Main.work(Main.java:49)
at Main.main(Main.java:23)
Special Judge 信息
Presentation Error | Unexpected end of file - int32 expected
系统信息
Exited with return code 1
599997
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
<1199907 bytes omitted>
标准错误流
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2000010
at Main.add(Main.java:89)
at Main.work(Main.java:49)
at Main.main(Main.java:23)
Special Judge 信息
Presentation Error | Unexpected end of file - int32 expected
系统信息
Exited with return code 1
599997
-2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2
<1799902 bytes omitted>
标准错误流
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2000010
at Main.add(Main.java:89)
at Main.work(Main.java:49)
at Main.main(Main.java:23)
Special Judge 信息
Presentation Error | Unexpected end of file - int32 expected
系统信息
Exited with return code 1
390556
191381 -199177 191381 -199177 191381 -199177 191381 -199177 191381 -199177 191381 -199177 191
<2925179 bytes omitted>
标准错误流
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2000010
at Main.add(Main.java:89)
at Main.work(Main.java:50)
at Main.main(Main.java:23)
Special Judge 信息
Presentation Error | Unexpected end of file - int32 expected
系统信息
Exited with return code 1
292643
1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -
<1316798 bytes omitted>
标准错误流
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2000010
at Main.add(Main.java:89)
at Main.work(Main.java:50)
at Main.main(Main.java:23)
Special Judge 信息
Presentation Error | Unexpected end of file - int32 expected
系统信息
Exited with return code 1
517013
1 1 -105107 1 1 -105107 1 1 -105107 1 1 411910 1 1 -105107 1 1 -105107 1 1 -105107 1 1 -10510
<2032921 bytes omitted>
标准错误流
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2000010
at Main.add(Main.java:89)
at Main.work(Main.java:50)
at Main.main(Main.java:23)
Special Judge 信息
Presentation Error | Unexpected end of file - int32 expected
系统信息
Exited with return code 1
599995
1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1
<1199903 bytes omitted>
标准错误流
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2000010
at Main.add(Main.java:89)
at Main.work(Main.java:49)
at Main.main(Main.java:23)
Special Judge 信息
Presentation Error | Unexpected end of file - int32 expected
系统信息
Exited with return code 1
标准错误流
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2000010
at Main.add(Main.java:89)
at Main.work(Main.java:49)
at Main.main(Main.java:23)
Special Judge 信息
Presentation Error | Unexpected end of file - int32 expected
系统信息
Exited with return code 1