답안 #289592

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
289592 2020-09-02T18:46:40 Z peti1234 Simurgh (IOI17_simurgh) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "simurgh.h"
using namespace std;
const int c=502;
vector<int> kerd;
vector<pair<int, int> > p;
int sz[c][c], st[c*c], v[c], n, m;
void dfs(int a, int b) {
    v[a]=b;
    for (int i=0; i<n; i++) {
        if (sz[a][i]!=-1 && !v[i]) {
            kerd.push_back(sz[a][i]);
            dfs(i, b);
        }
    }
}
vector<int> find_roads(int k, vector<int> x, vector<int> y) {
    m=x.size(), n=k;
    for (int i=0; i<n; i++) for (int j=0; j<n; j++) sz[i][j]=-1;
    for (int i=0; i<m; i++) {
        int a=x[i], b=y[i];
        sz[a][b]=i, sz[b][0]=i;
    }
    for (int i=0; i<m; i++) {
        if (!st[i]) {
            kerd.clear(), p.clear();
            int a=x[i], b=y[i];
            for (int j=0; j<n; j++) v[j]=0;
            v[b]=1, dfs(a, 1), dfs(b, 2);
            for (int i=0; i<m; i++) if (!st[i] && v[x[i]]!=v[y[i]]) {
                kerd.push_back(i);
                p.push_back({count_common_roads(kerd), i});
                kerd.pop_back();
            }
            sort(p.rbegin(), r.end());
            for (int i=0; i<p.size(); i++) {
                int se=p[i].second;
                if (p[i].first==p[0].first) st[p]=1;
                else st[p]=-1;
            }
        }
    }
    for (int i=0; i<m; i++) if (st[i]==1) kerd.push_back(i);
    return kerd;
}

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:35:30: error: 'r' was not declared in this scope
   35 |             sort(p.rbegin(), r.end());
      |                              ^
simurgh.cpp:36:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |             for (int i=0; i<p.size(); i++) {
      |                           ~^~~~~~~~~
simurgh.cpp:38:47: error: no match for 'operator[]' (operand types are 'int [252004]' and 'std::vector<std::pair<int, int> >')
   38 |                 if (p[i].first==p[0].first) st[p]=1;
      |                                               ^
simurgh.cpp:39:24: error: no match for 'operator[]' (operand types are 'int [252004]' and 'std::vector<std::pair<int, int> >')
   39 |                 else st[p]=-1;
      |                        ^
simurgh.cpp:37:21: warning: unused variable 'se' [-Wunused-variable]
   37 |                 int se=p[i].second;
      |                     ^~