Submission #375312

# Submission time Handle Problem Language Result Execution time Memory
375312 2021-03-09T07:17:35 Z rrrr10000 Xylophone (JOI18_xylophone) C++14
100 / 100
97 ms 492 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=(ll)(k);i<(ll)(n);i++)
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define dame(a) {out(a);return 0;}
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> void outp(T p){printf("(%d,%d)",p.fi,p.se);}
template<class T> void outvp(T v){for(auto p:v)printf("(%d,%d)",p.fi,p.se);}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
/*ll query(ll a,ll b){
    return 0;
}
void answer(vector<int> v){
    outv(v);
}*/
#include "xylophone.h"
void solve(int n){
    vector<int> dif(n-1),ans(n);
    rep(i,n-1)dif[i]=query(i+1,i+2);
    ans[1]=dif[0];
    REP(i,2,n){
        ll t=query(i-1,i+1);
        if(dif[i-2]+dif[i-1]==t){
            if(ans[i-2]<ans[i-1])ans[i]=ans[i-1]+dif[i-1];
            else ans[i]=ans[i-1]-dif[i-1];
        }
        else{
            if(ans[i-2]>ans[i-1])ans[i]=ans[i-1]+dif[i-1];
            else ans[i]=ans[i-1]-dif[i-1];
        }
    }
    int mi=0;
    rep(i,n)chmin(mi,ans[i]);
    rep(i,n)ans[i]-=mi-1;
    ll a,b;
    rep(i,n){
        if(ans[i]==1)a=i;
        if(ans[i]==n)b=i;
    }
    if(a>b){
        rep(i,n)ans[i]=n+1-ans[i];
    }
    rep(i,n)answer(i+1,ans[i]);
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:55:5: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
   55 |     if(a>b){
      |     ^~
xylophone.cpp:55:5: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 3 ms 364 KB Output is correct
8 Correct 3 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 3 ms 364 KB Output is correct
8 Correct 3 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 5 ms 364 KB Output is correct
17 Correct 9 ms 364 KB Output is correct
18 Correct 11 ms 384 KB Output is correct
19 Correct 19 ms 364 KB Output is correct
20 Correct 18 ms 364 KB Output is correct
21 Correct 17 ms 364 KB Output is correct
22 Correct 15 ms 364 KB Output is correct
23 Correct 24 ms 364 KB Output is correct
24 Correct 19 ms 364 KB Output is correct
25 Correct 19 ms 364 KB Output is correct
26 Correct 16 ms 364 KB Output is correct
27 Correct 18 ms 364 KB Output is correct
28 Correct 15 ms 364 KB Output is correct
29 Correct 15 ms 364 KB Output is correct
30 Correct 19 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 3 ms 364 KB Output is correct
8 Correct 3 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 5 ms 364 KB Output is correct
17 Correct 9 ms 364 KB Output is correct
18 Correct 11 ms 384 KB Output is correct
19 Correct 19 ms 364 KB Output is correct
20 Correct 18 ms 364 KB Output is correct
21 Correct 17 ms 364 KB Output is correct
22 Correct 15 ms 364 KB Output is correct
23 Correct 24 ms 364 KB Output is correct
24 Correct 19 ms 364 KB Output is correct
25 Correct 19 ms 364 KB Output is correct
26 Correct 16 ms 364 KB Output is correct
27 Correct 18 ms 364 KB Output is correct
28 Correct 15 ms 364 KB Output is correct
29 Correct 15 ms 364 KB Output is correct
30 Correct 19 ms 384 KB Output is correct
31 Correct 40 ms 364 KB Output is correct
32 Correct 51 ms 364 KB Output is correct
33 Correct 87 ms 364 KB Output is correct
34 Correct 89 ms 364 KB Output is correct
35 Correct 82 ms 416 KB Output is correct
36 Correct 84 ms 416 KB Output is correct
37 Correct 91 ms 492 KB Output is correct
38 Correct 88 ms 492 KB Output is correct
39 Correct 80 ms 364 KB Output is correct
40 Correct 78 ms 364 KB Output is correct
41 Correct 88 ms 364 KB Output is correct
42 Correct 90 ms 492 KB Output is correct
43 Correct 89 ms 492 KB Output is correct
44 Correct 75 ms 492 KB Output is correct
45 Correct 96 ms 416 KB Output is correct
46 Correct 95 ms 492 KB Output is correct
47 Correct 94 ms 416 KB Output is correct
48 Correct 89 ms 492 KB Output is correct
49 Correct 85 ms 492 KB Output is correct
50 Correct 70 ms 416 KB Output is correct
51 Correct 97 ms 492 KB Output is correct
52 Correct 89 ms 492 KB Output is correct
53 Correct 95 ms 492 KB Output is correct
54 Correct 91 ms 364 KB Output is correct
55 Correct 89 ms 364 KB Output is correct
56 Correct 54 ms 364 KB Output is correct
57 Correct 95 ms 364 KB Output is correct
58 Correct 91 ms 492 KB Output is correct
59 Correct 86 ms 492 KB Output is correct
60 Correct 92 ms 364 KB Output is correct