Submission #954108

#TimeUsernameProblemLanguageResultExecution timeMemory
954108irmuunXylophone (JOI18_xylophone)C++17
100 / 100
57 ms700 KiB
#include<bits/stdc++.h> #include "xylophone.h" using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() void solve(int n){ int a[n+5]; a[1]=0; int d[n+5]; for(int i=1;i<n;i++){ d[i]=query(i,i+1); } a[2]=d[1]; bool add=true; for(int i=3;i<=n;i++){ int D=query(i-2,i); if(d[i-2]+d[i-1]==D){ if(add){ a[i]=a[i-1]+d[i-1]; } else{ a[i]=a[i-1]-d[i-1]; } } else{ if(add) add=false; else add=true; if(add){ a[i]=a[i-1]+d[i-1]; } else{ a[i]=a[i-1]-d[i-1]; } } } int mn=1e9; for(int i=1;i<=n;i++){ mn=min(mn,a[i]); } mn=-mn+1; bool flag=false,ok=true; for(int i=1;i<=n;i++){ a[i]+=mn; if(a[i]==1){ flag=true; } if(a[i]==n){ if(!flag){ ok=false; } } } if(!ok){ for(int i=1;i<=n;i++){ a[i]=n+1-a[i]; } } for(int i=1;i<=n;i++){ answer(i,a[i]); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...