답안 #1113018

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1113018 2024-11-15T12:11:11 Z SalihSahin Simurgh (IOI17_simurgh) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define pb push_back
#include "simurgh.h"

using namespace std;

const int MAXN = 5e2 + 5;
vector<int> par(MAXN);
vector<pair<int, int> > adj[MAXN];

int fnd(int a){
   if(a == par[a]) return a;
   return par[a] = fnd(par[a]);
}

void merge(int a, int b){
   a = fnd(a), b = fnd(b);
   par[b] = a;
}

vector<int> find_roads(int n, vector<int> u, vector<int> v) {
   vector<int> r;
   vector<int> ok(m);
   int m = u.size();
   for(int i = 0; i < m; i++){
      adj[u[i]].pb({v[i], i});
      adj[v[i]].pb({u[i], i});
   }

   for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
         par[j] = j;
      }
      vector<int> ottree;
      for(int j = 0; j < n; j++){
         if(j == i) continue;
         for(auto itr: adj[j]){
            if(itr.first == i) continue;
            if(fnd(j) == fnd(itr.first)) continue;
            ottree.pb(itr.second);
            merge(j, itr.first);
         }
      }
      vector<pair<int, int> > vals;
      int mx = 0;
      for(auto itr: adj[i]){
         ottree.pb(itr.second);
         int cnt = count_common_roads(ottree);
         vals.pb({cnt, itr.second});
         mx = max(mx, cnt);
         ottree.pop_back();
      }
      for(auto itr: vals){
         if(itr.first == mx){
            ok[itr.second] = 1;
         }
      }
   }

   for(int i = 0; i < m; i++){
      if(ok[i]) r.pb(i);
   }
   
   return r;
}

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:23:19: error: 'm' was not declared in this scope
   23 |    vector<int> ok(m);
      |                   ^