Submission #201996

#TimeUsernameProblemLanguageResultExecution timeMemory
201996SegtreeXylophone (JOI18_xylophone)C++14
100 / 100
103 ms436 KiB
#include<iostream> #include<algorithm> #include<vector> #include<queue> #include<set> #include<unordered_set> #include<unordered_map> #include"xylophone.h" using namespace std; typedef long long ll; #define chmax(a,b) a=max(a,b) #define chmin(a,b) a=min(a,b) #define all(x) x.begin(),x.end() #define rep(i,n) for(int i=0;i<n;i++) #define mod 1000000007 #define mad(a,b) a=(a+b)%mod /*ll val[5010],cnt; ll query(ll s,ll t){ cnt++; ll ma=-1e17,mi=1e17; for(int i=s;i<=t;i++){ chmax(ma,val[i]); chmin(mi,val[i]); } return ma-mi; } void answer(ll i,ll x){ cout<<i<<":"<<x<<endl; }*/ void solve(int n){ ll a[5010]; a[1]=0,a[2]=query(1,2); for(int i=3;i<=n;i++){ ll x=query(i-1,i); ll y=query(i-2,i); if(abs(a[i-2]-a[i-1])+x==y){ if(a[i-2]<a[i-1])a[i]=a[i-1]+x; else a[i]=a[i-1]-x; } else{ if(a[i-2]<a[i-1])a[i]=a[i-1]-x; else a[i]=a[i-1]+x; } } ll mi=1e17,ma=-1e17,pmi,pma; for(int i=1;i<=n;i++){ if(mi>a[i])mi=a[i],pmi=i; if(ma<a[i])ma=a[i],pma=i; } for(int i=1;i<=n;i++)a[i]=a[i]-mi+1; if(pmi>pma)for(int i=1;i<=n;i++)a[i]=n+1-a[i]; for(int i=1;i<=n;i++){ answer(i,a[i]); } } /*int main(){ ll n; cin>>n; for(int i=1;i<=n;i++)cin>>val[i]; cnt=0; solve(n); cout<<"cnt="<<cnt<<endl; }*/

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:51:5: warning: 'pma' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if(pmi>pma)for(int i=1;i<=n;i++)a[i]=n+1-a[i];
     ^~
xylophone.cpp:51:5: warning: 'pmi' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...