답안 #918646

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
918646 2024-01-30T08:22:47 Z viwlesxq Xylophone (JOI18_xylophone) C++17
47 / 100
35 ms 440 KB
#include <bits/stdc++.h>
using namespace std;
#include "xylophone.h"

void solve(int n) {
    vector<int> a(n + 1);
    int min = 1, max = n;
    for (int i = 2; i <= n; ++i) {
        if (query(i, n) != n - 1) break;
        min = i;
    }
    for (int i = n - 1; i > 0; --i) {
        if (query(1, i) != n - 1) break;
        max = i;
    }
    a[min] = 1, a[max] = n;
    int last = min, sum = 0;
    bool increasing = true;
    for (int i = min - 1; i > 0; --i) {
        int diff = query(i, last), add = query(i, i + 1);
        if (sum + add != diff) {
            last = i + 1, sum = 0;
            increasing ^= true;
        }
        a[i] = a[i + 1] + (increasing ? add : -add);
        sum += add;
    }
    last = min, sum = 0;
    increasing = true;
    for (int i = min + 1; i < max; ++i) {
        int diff = query(last, i), add = query(i - 1, i);
        if (sum + add != diff) {
            last = i - 1, sum = 0;
            increasing ^= true;
        }
        a[i] = a[i - 1] + (increasing ? add : -add);
        sum += add;
    }
    last = max, sum = 0;
    increasing = false;
    for (int i = max + 1; i <= n; ++i) {
        int diff = query(last, i), add = query(i - 1, i);
        if (sum + add != diff) {
            last = i - 1, sum = 0;
            increasing ^= true;
        }
        a[i] = a[i - 1] + (increasing ? add : -add);
        sum += add;
    }
    for (int i = 1; i <= n; ++i) {
        answer(i, a[i]);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 5 ms 344 KB Output is correct
18 Correct 8 ms 440 KB Output is correct
19 Correct 11 ms 344 KB Output is correct
20 Correct 10 ms 440 KB Output is correct
21 Correct 14 ms 428 KB Output is correct
22 Correct 9 ms 440 KB Output is correct
23 Correct 8 ms 432 KB Output is correct
24 Correct 13 ms 344 KB Output is correct
25 Correct 13 ms 436 KB Output is correct
26 Correct 9 ms 440 KB Output is correct
27 Correct 11 ms 432 KB Output is correct
28 Correct 13 ms 344 KB Output is correct
29 Correct 11 ms 344 KB Output is correct
30 Correct 9 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 5 ms 344 KB Output is correct
18 Correct 8 ms 440 KB Output is correct
19 Correct 11 ms 344 KB Output is correct
20 Correct 10 ms 440 KB Output is correct
21 Correct 14 ms 428 KB Output is correct
22 Correct 9 ms 440 KB Output is correct
23 Correct 8 ms 432 KB Output is correct
24 Correct 13 ms 344 KB Output is correct
25 Correct 13 ms 436 KB Output is correct
26 Correct 9 ms 440 KB Output is correct
27 Correct 11 ms 432 KB Output is correct
28 Correct 13 ms 344 KB Output is correct
29 Correct 11 ms 344 KB Output is correct
30 Correct 9 ms 436 KB Output is correct
31 Correct 21 ms 420 KB Output is correct
32 Correct 35 ms 436 KB Output is correct
33 Incorrect 34 ms 344 KB Wrong Answer [2]
34 Halted 0 ms 0 KB -