답안 #289594

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
289594 2020-09-02T18:47:53 Z peti1234 Simurgh (IOI17_simurgh) C++17
0 / 100
1 ms 384 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(), p.rend());
            for (int i=0; i<p.size(); i++) {
                int se=p[i].second;
                if (p[i].first==p[0].first) st[se]=1;
                else st[se]=-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: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++) {
      |                           ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB correct
2 Incorrect 1 ms 384 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB WA in grader: NO
2 Halted 0 ms 0 KB -