답안 #128275

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
128275 2019-07-10T15:48:57 Z miguel Xylophone (JOI18_xylophone) C++14
47 / 100
113 ms 408 KB
#include<bits/stdc++.h>
#include <xylophone.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <int, pi>
#define vi vector <int>
const ll mod = 1e9 + 7;

void solve(int n){
    int t[5001];
    int l=1, r=n;
    while(r-l>1){
        int mid=(l+r)/2;
        if(query(1, mid)!=n-1) l=mid;
        else r=mid;
    }
    int mx=r;
    l=1, r=mx;
    while(r-l>1){
        int mid=(l+r)/2;
        if(query(mid, mx)!=n-1) r=mid;
        else l=mid;
    }
    int mn=l;
    t[mn]=1, t[mx]=n;
    if(mn>1) t[mn-1]=query(mn-1, mn)+1;
    t[mn+1]=query(mn, mn+1)+1;
    if(mx<n) t[mx+1]=n-query(mx, mx+1);
    t[mx-1]=n-query(mx-1, mx);
    for(int i=mn-1; i>=2; i--){
        int q1=query(i-1, i+1), q2=query(i-1, i), q3=query(i, i+1);
        if(q1==q2+q3){

            if(t[i+1]>t[i]) t[i-1]=t[i]-q2;
            else t[i-1]=t[i]+q2;
        }
        else{
            if(t[i+1]>t[i]) t[i-1]=t[i]+q2;
            else t[i-1]=t[i]-q2;
        }
    }
    for(int i=mn+1; i<=mx-2; i++){
        int q1=query(i-1, i+1), q2=query(i-1, i), q3=query(i, i+1);
        if(q1==q2+q3){//cout<<i<<"mamamia"<<endl;
            if(t[i-1]>t[i]) t[i+1]=t[i]-q3;
            else t[i+1]=t[i]+q3;
        }
        else{
            if(t[i-1]>t[i]) t[i+1]=t[i]+q3;
            else t[i+1]=t[i]-q3;
        }
    }
    for(int i=mx+1; i<=n-1; i++){
        int q1=query(i-1, i+1), q2=query(i-1, i), q3=query(i, i+1);
        if(q1==q2+q3){
            if(t[i-1]>t[i]) t[i+1]=t[i]-q3;
            else t[i+1]=t[i]+q3;
        }
        else{
            if(t[i-1]>t[i]) t[i+1]=t[i]+q3;
            else t[i+1]=t[i]-q3;
        }
    }
    //for(int i=1; i<=n; i++) cout<<t[i]<<"x ";
    for(int i=1; i<=n; i++) answer(i, t[i]);
    //cout<<mn<<" "<<mx<<endl;
}



# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 3 ms 248 KB Output is correct
4 Correct 4 ms 324 KB Output is correct
5 Correct 6 ms 248 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 8 ms 376 KB Output is correct
8 Correct 7 ms 376 KB Output is correct
9 Correct 6 ms 296 KB Output is correct
10 Correct 8 ms 376 KB Output is correct
11 Correct 3 ms 296 KB Output is correct
12 Correct 4 ms 248 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 4 ms 248 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 3 ms 248 KB Output is correct
4 Correct 4 ms 324 KB Output is correct
5 Correct 6 ms 248 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 8 ms 376 KB Output is correct
8 Correct 7 ms 376 KB Output is correct
9 Correct 6 ms 296 KB Output is correct
10 Correct 8 ms 376 KB Output is correct
11 Correct 3 ms 296 KB Output is correct
12 Correct 4 ms 248 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 4 ms 248 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 13 ms 320 KB Output is correct
17 Correct 9 ms 404 KB Output is correct
18 Correct 26 ms 376 KB Output is correct
19 Correct 18 ms 316 KB Output is correct
20 Correct 30 ms 248 KB Output is correct
21 Correct 34 ms 248 KB Output is correct
22 Correct 32 ms 376 KB Output is correct
23 Correct 32 ms 248 KB Output is correct
24 Correct 18 ms 328 KB Output is correct
25 Correct 32 ms 248 KB Output is correct
26 Correct 32 ms 252 KB Output is correct
27 Correct 39 ms 248 KB Output is correct
28 Correct 32 ms 328 KB Output is correct
29 Correct 17 ms 408 KB Output is correct
30 Correct 40 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 3 ms 248 KB Output is correct
4 Correct 4 ms 324 KB Output is correct
5 Correct 6 ms 248 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 8 ms 376 KB Output is correct
8 Correct 7 ms 376 KB Output is correct
9 Correct 6 ms 296 KB Output is correct
10 Correct 8 ms 376 KB Output is correct
11 Correct 3 ms 296 KB Output is correct
12 Correct 4 ms 248 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 4 ms 248 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 13 ms 320 KB Output is correct
17 Correct 9 ms 404 KB Output is correct
18 Correct 26 ms 376 KB Output is correct
19 Correct 18 ms 316 KB Output is correct
20 Correct 30 ms 248 KB Output is correct
21 Correct 34 ms 248 KB Output is correct
22 Correct 32 ms 376 KB Output is correct
23 Correct 32 ms 248 KB Output is correct
24 Correct 18 ms 328 KB Output is correct
25 Correct 32 ms 248 KB Output is correct
26 Correct 32 ms 252 KB Output is correct
27 Correct 39 ms 248 KB Output is correct
28 Correct 32 ms 328 KB Output is correct
29 Correct 17 ms 408 KB Output is correct
30 Correct 40 ms 248 KB Output is correct
31 Correct 69 ms 328 KB Output is correct
32 Correct 82 ms 376 KB Output is correct
33 Incorrect 113 ms 376 KB Wrong Answer [2]
34 Halted 0 ms 0 KB -