제출 #1141568

#제출 시각아이디문제언어결과실행 시간메모리
1141568Noproblem29Xylophone (JOI18_xylophone)C++20
0 / 100
0 ms436 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; #define ll long long static int A[5000]; int b[5005]; int e[5005]; int c[5005]; int d[5005]; void solve(int n) { for(int i=1;i+1<=n;i++){ c[i]=query(i,i+1); } for(int i=1;i+2<=n;i++){ d[i]=query(i,i+2); } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ b[j]=0; e[j]=0; } b[i]=1; b[i+1]=c[i]+1; for(int j=i+2;j<=n;j++){ if(c[j-2]+c[j-1]!=d[j-2]){ b[j]=b[j-1]-c[j-1]; } else{ b[j]=b[j-1]+c[j-1]; } } b[i-1]=c[i-1]+1; for(int j=i-2;j>=1;j--){ if(c[j+1]+c[j]!=d[j]){ b[j]=b[j+1]-c[j]; } else{ b[j]=b[j+1]+c[j]; } } bool ok=1; for(int j=1;j<=n;j++){ if(b[j]<1||b[j]>n||e[b[j]]){ ok=0; break; } e[b[j]]=1; } if(ok){ for(int j=1;j<=n;j++){ answer(j,b[j]); // cout<<b[j]<<' '; } // cout<<'\n'; return; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...