Submission #914518

#TimeUsernameProblemLanguageResultExecution timeMemory
914518manizareXylophone (JOI18_xylophone)C++14
100 / 100
60 ms5292 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...