제출 #363137

#제출 시각아이디문제언어결과실행 시간메모리
363137Bill_00Xylophone (JOI18_xylophone)C++14
0 / 100
1 ms512 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; static int A[5000]; void solve(int n) { if(n==2){ answer(1,1); answer(2,n); return; } int a[5005],b[5005],c[5005]; for(int i=1;i<n;i++){ a[i]=query(i,i+1); } int val=query(1,3); if(val==a[1]+a[2]){ b[1]=1; b[2]=1; } else{ b[1]=1; b[2]=-1; } for(int i=2;i<n-1;i++){ int val=query(i,i+2); if(val==a[i]+a[i+1]){ if(b[i]==1) b[i+1]=1; else b[i+1]=-1; } else{ if(b[i]==1) b[i+1]=-1; else b[i+1]=1; } } c[1]=0; for(int i=2;i<=n;i++){ c[i]=c[i-1]+a[i]*b[i]; } pair<int,int>mx={-(n+1),-1},mn={n+1,-1}; for(int i=1;i<=n;i++){ mx=max(mx,{c[i],i}); mn=min(mn,{c[i],i}); } if(mx.second<mn.second){ for(int i=1;i<=n;i++){ c[i]=-c[i]; } } int ihesgegch=1-mn.first; for(int i=1;i<=n;i++){ answer(i,c[i]+ihesgegch); } }

컴파일 시 표준 에러 (stderr) 메시지

xylophone.cpp:4:12: warning: 'A' defined but not used [-Wunused-variable]
    4 | static int A[5000];
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...