# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
751687 | 2023-06-01T08:13:16 Z | sofija6 | Xylophone (JOI18_xylophone) | C++14 | 1 ms | 208 KB |
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; static int A[5000]; void solve(int N) { int diff2[N+2],diff3[N+2]; for (int i=1;i<N;i++) { if (i<N-1) diff3[i]=query(i,i+2); diff2[i]=query(i,i+1); } for (int i=1;i<=N;i++) { int cur=1; A[1]=i; for (int j=2;j<=N;j++) { if (j>1 && N>2 && j<N && diff3[j-1]!=diff2[j-1]+diff2[j]) cur*=(-1); else if (N>2 && j==N && diff3[j-2]!=diff2[j-2]+diff2[j-1]) cur*=(-1); A[j]=A[j-1]+diff2[j-1]*cur; } set<int> s; for (int j=1;j<=N;j++) { if (A[j]<=N && A[j]>=1) s.insert(A[j]); } if (s.size()==N) { for (int j=1;j<=N;j++) answer(j,A[j]); return; } s.clear(); cur=-1; for (int j=2;j<=N;j++) { if (j>1 && N>2 && diff3[j-1]!=diff2[j-1]+diff2[j]) cur*=(-1); else if (N>2 && j==N && diff3[j-2]!=diff2[j-2]+diff2[j-1]) cur*=(-1); A[j]=A[j-1]+diff2[j-1]*cur; } for (int j=1;j<=N;j++) { if (A[j]<=N && A[j]>=1) s.insert(A[j]); } if (s.size()==N) { for (int j=1;j<=N;j++) answer(j,A[j]); return; } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Incorrect | 1 ms | 208 KB | Wrong Answer [6] |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Incorrect | 1 ms | 208 KB | Wrong Answer [6] |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Incorrect | 1 ms | 208 KB | Wrong Answer [6] |
4 | Halted | 0 ms | 0 KB | - |