Submission #590488

# Submission time Handle Problem Language Result Execution time Memory
590488 2022-07-06T03:42:14 Z Do_you_copy Xylophone (JOI18_xylophone) C++14
47 / 100
94 ms 436 KB
#include <bits/stdc++.h>
#include <xylophone.h>
#define taskname "test"
#define fi first
#define se second
#define pb push_back
#define faster ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
 
using ll = long long;
using pii = pair <int, int>;
 
ll min(const ll &a, const ll &b){
    return (a < b) ? a : b;
}
 
ll max(const ll &a, const ll &b){
    return (a > b) ? a : b;
}
 
const ll Mod = 1000000007;
const int maxN = 1e5 + 1;
int n;
int a[maxN];
 
bool counted[maxN];
 
void solve(int N){
    n = N;
    int l = 1, r = n - 1;
    while (l <= r){
        int m = (l + r) / 2;
        if (query(m, n) == n - 1) l = m + 1;
        else r = m - 1;
    }
    a[r] = 1;
    answer(r, a[r]);
    a[r + 1] = a[r] + query(r, r + 1);
    answer(r + 1, a[r + 1]);
    for (int i = r + 2; i <= n; ++i){
        int x = a[i - 2];
        int y = a[i - 1];
        int d2 = query(i - 1, i);
        if (a[i - 1] + d2 > n || counted[a[i - 1] + d2]){
            a[i] = a[i - 1] - d2;
            answer(i, a[i]);
            continue;
        }
        if (a[i - 1] - d2 < 1 || counted[a[i - 1] - d2]){
            a[i] = a[i - 1] + d2;
            answer(i, a[i]);
            continue;
        }
        int d1 = query(i - 2, i);
        int c = a[i - 1] - d2;
        int minn = min(min(c, a[i - 1]), a[i - 2]);
        int maxx = max(max(c, a[i - 1]), a[i - 2]);
        if (query(i - 2, i) == maxx - minn){
            a[i] = c;
            answer(i, c);
        }
        else{
            a[i] = a[i - 1] + d2;
            answer(i, a[i]);
        }
        counted[a[i]] = 1;
    }
    if (r > 1){
        a[r - 1] = a[r] + query(r - 1, r);
        answer(r - 1, a[r - 1]);
    }
    for (int i = r - 2; i >= 1; --i){
        int x = a[i + 2];
        int y = a[i + 1];
        int d2 = query(i, i + 1);
        if (a[i + 1] + d2 > n || counted[a[i + 1] + d2]){
            a[i] = a[i + 1] - d2;
            answer(i, a[i]);
            continue;
        }
        if (a[i + 1] - d2 < 1 || counted[a[i + 1] - d2]){
            a[i] = a[i + 1] + d2;
            answer(i, a[i]);
            continue;
        }
        int d1 = query(i, i + 2);
        int c = a[i + 1] - d2;
        int minn = min(min(c, a[i + 1]), a[i + 2]);
        int maxx = max(max(c, a[i + 1]), a[i + 2]);
        if (query(i, i + 2) == maxx - minn){
            a[i] = c;
            answer(i, c);
        }
        else{
            a[i] = a[i + 1] + d2;
            answer(i, a[i]);
        }
        counted[a[i]] = 1;
    }
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:41:13: warning: unused variable 'x' [-Wunused-variable]
   41 |         int x = a[i - 2];
      |             ^
xylophone.cpp:42:13: warning: unused variable 'y' [-Wunused-variable]
   42 |         int y = a[i - 1];
      |             ^
xylophone.cpp:54:13: warning: unused variable 'd1' [-Wunused-variable]
   54 |         int d1 = query(i - 2, i);
      |             ^~
xylophone.cpp:73:13: warning: unused variable 'x' [-Wunused-variable]
   73 |         int x = a[i + 2];
      |             ^
xylophone.cpp:74:13: warning: unused variable 'y' [-Wunused-variable]
   74 |         int y = a[i + 1];
      |             ^
xylophone.cpp:86:13: warning: unused variable 'd1' [-Wunused-variable]
   86 |         int d1 = query(i, i + 2);
      |             ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
5 Correct 2 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 2 ms 208 KB Output is correct
9 Correct 2 ms 208 KB Output is correct
10 Correct 2 ms 208 KB Output is correct
11 Correct 2 ms 304 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 3 ms 208 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 3 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
5 Correct 2 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 2 ms 208 KB Output is correct
9 Correct 2 ms 208 KB Output is correct
10 Correct 2 ms 208 KB Output is correct
11 Correct 2 ms 304 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 3 ms 208 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 3 ms 208 KB Output is correct
16 Correct 4 ms 208 KB Output is correct
17 Correct 9 ms 308 KB Output is correct
18 Correct 11 ms 208 KB Output is correct
19 Correct 12 ms 208 KB Output is correct
20 Correct 21 ms 308 KB Output is correct
21 Correct 16 ms 208 KB Output is correct
22 Correct 16 ms 208 KB Output is correct
23 Correct 8 ms 308 KB Output is correct
24 Correct 14 ms 208 KB Output is correct
25 Correct 15 ms 308 KB Output is correct
26 Correct 19 ms 304 KB Output is correct
27 Correct 17 ms 288 KB Output is correct
28 Correct 18 ms 208 KB Output is correct
29 Correct 16 ms 208 KB Output is correct
30 Correct 17 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
5 Correct 2 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 2 ms 208 KB Output is correct
9 Correct 2 ms 208 KB Output is correct
10 Correct 2 ms 208 KB Output is correct
11 Correct 2 ms 304 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 3 ms 208 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 3 ms 208 KB Output is correct
16 Correct 4 ms 208 KB Output is correct
17 Correct 9 ms 308 KB Output is correct
18 Correct 11 ms 208 KB Output is correct
19 Correct 12 ms 208 KB Output is correct
20 Correct 21 ms 308 KB Output is correct
21 Correct 16 ms 208 KB Output is correct
22 Correct 16 ms 208 KB Output is correct
23 Correct 8 ms 308 KB Output is correct
24 Correct 14 ms 208 KB Output is correct
25 Correct 15 ms 308 KB Output is correct
26 Correct 19 ms 304 KB Output is correct
27 Correct 17 ms 288 KB Output is correct
28 Correct 18 ms 208 KB Output is correct
29 Correct 16 ms 208 KB Output is correct
30 Correct 17 ms 208 KB Output is correct
31 Correct 40 ms 308 KB Output is correct
32 Correct 45 ms 300 KB Output is correct
33 Correct 71 ms 292 KB Output is correct
34 Correct 38 ms 436 KB Output is correct
35 Correct 94 ms 312 KB Output is correct
36 Incorrect 90 ms 312 KB Wrong Answer [2]
37 Halted 0 ms 0 KB -