Submission #433645

#TimeUsernameProblemLanguageResultExecution timeMemory
433645AmineTrabelsiXylophone (JOI18_xylophone)C++14
0 / 100
2 ms200 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; void solve(int N) { /* int value = query(1, N); for(int i = 1; i <= N; i++) { answer(i, i); } */ int low = 1,high = N; /* // prefix while(low != high){ int mid = (low+high)/2; if(query(1,mid) == N-1){ high = mid; }else low = mid+1; } int five = high; */ low = 1, high = N; while(low != high){ int mid = (low+high+1)/2; if(query(mid,N) == N-1){ low = mid; }else high = mid-1; } int one = low; vector<int> A(N+1,0); A[one] = 1; //A[five] = 5; //cerr<< low <<" "<<high<< '\n'; int prev = 1; if(one > 1){ int q = query(one-1,one); A[one-1] = 1+q; prev = q; } for(int i=one-2;i>=1;i--){ int q = query(i,i+1); int sq = query(i,one); if(sq > prev){ A[i] = A[i+1]+q; }else{ A[i] = A[i+1]-q; } prev = sq; } for(int i = 1; i <= N; i++) { cerr<<A[i] << ' '; }cerr<<'\n'; if(one+1 <= N){ int q = query(one,one+1); A[one+1] = 1+q; prev = q; } for(int i = 1; i <= N; i++) { cerr<<A[i] << ' '; }cerr<<'\n'; for(int i=one+2;i<=N;i++){ int q = query(i-1,i); int sq = query(one,i); if(sq > prev){ A[i] = A[i-1]+q; }else{ A[i] = A[i-1]-q; } prev = sq; } for(int i = 1; i <= N; i++) { cerr<<A[i] << ' '; }cerr<<'\n'; 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...