Submission #1197470

#TimeUsernameProblemLanguageResultExecution timeMemory
1197470adiyerFun Tour (APIO20_fun)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "fun.h" using namespace std; int a[1000][1000]; std::vector<int> createFunTour(int N, int Q) { int val = 0, st = 0; for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ a[i][j] = hoursRequired(i, j); if(a[i][j] >= val) st = i; } } vector < int > ans; int was[N] = {}, lst = st; was[lst] = 1, ans.push_back(lst); for(int i = 0; i < N - 1; i++){ int k = -1; for(int j = 0; j < N; j++){ if(!was[j]){ if((k == -1 || a[lst][j] >= a[lst][k]) && a[lst][j] <= val){ k = j; } } } val = a[lst][j]; was[k] = 1; ans.push_back(k); lst = k; } return ans; }

Compilation message (stderr)

fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:28:22: error: 'j' was not declared in this scope
   28 |         val = a[lst][j];
      |                      ^