# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
565588 | birthdaycake | Xylophone (JOI18_xylophone) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "xylophone.h"
using namespace std;
int A[5001][5001];
int ans[5001];
void solve(int N) {
for(int i = 1; i <= N; i++) ans[i] = 0;
for(int i = 1; i <= N; i++){
for(int j = i + 1; j <= N; j++){
int value = query(i,j);
A[i][j] = value;
A[j][i] = value;
}
}
int j = 0;
for(int i = 1; i <= N; i++){
set<int>x;
for(int j = 1; j <= N; j++){
x.insert(A[i][j]);
}
if(x.size() == n){
ans[i] = N;
j = i;
break;
}
}
for(int i = 1; i <= N; i++){
if(i != j) {
ans[i] = abs(N - ans[i][j]);
}
}
for(int i = 1; i <= N; i++) {
answer(i, ans[i]);
}
}