This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "xylophone.h"
#pragma GCC optimize("O3,unroll-loops")
#define pb push_back
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define pii pair <int,int>
#define PII pair<pii , pii>
#define ld long double
#define sz(v) (int)v.size()
#define rep(i , a , b) for(int i=a;i <= (b);i++)
#define per(i , a , b) for(int i=a;i >= (b);i--)
using namespace std ;
const int maxn = 1e6 + 10 , inf= 2e9 , mod = 1e9 + 7 , sq = 360 ,MX = 20000 ;
int p[maxn] , a[maxn] , d[maxn] , nd[maxn] ;
void solve(int n){
rep(i , 1, n-1){
d[i] = query(i , i+1) ;
nd[i] = d[i] ;
}
rep(i , 1, n-2){
if(d[i]+d[i+1]!=query(i ,i+2)){
if(nd[i]>0)nd[i+1] = -d[i+1] ;
}else{
if(nd[i]<0)nd[i+1] = -d[i+1] ;
}
}
int mn= 0 ;
p[1] =0 ;
rep(i , 2, n){
p[i] = p[i-1] + nd[i-1] ;
mn = min(mn , p[i]) ;
}
rep(i , 1, n){
p[i]+=-mn+1;
}
rep(i , 1, n){
if(p[i] == n){
rep(i , 1, n){
p[i] = n+1 - p[i] ;
}
break ;
}
if(p[i]==1)break ;
}
rep(i ,1 , n){
answer(i , p[i]) ;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |