Submission #565588

#TimeUsernameProblemLanguageResultExecution timeMemory
565588birthdaycakeXylophone (JOI18_xylophone)C++17
Compilation error
0 ms0 KiB
#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]); } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:30:24: error: 'n' was not declared in this scope
   30 |         if(x.size() == n){
      |                        ^
xylophone.cpp:40:36: error: invalid types 'int[int]' for array subscript
   40 |             ans[i] = abs(N - ans[i][j]);
      |                                    ^