제출 #590486

#제출 시각아이디문제언어결과실행 시간메모리
590486Do_you_copyXylophone (JOI18_xylophone)C++14
0 / 100
1 ms208 KiB
#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 >= n; --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 + 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;
    }
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...