답안 #864317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
864317 2023-10-22T11:44:00 Z raphaelp 관광 (NOI14_sightseeing) C++14
0 / 25
2079 ms 102724 KB
#include <bits/stdc++.h>
using namespace std;
int UF[500000];
int Rank[500000];
int num = 0;
int find(int x)
{
    return (x == UF[x]) ? x : (UF[x] = find(UF[x]));
}
bool merge(int a, int b)
{
    a = find(a);
    b = find(b);
    if (a == b)
        return false;
    if (Rank[b] > Rank[a])
        swap(a, b);
    UF[b] = a;
    if (Rank[b] == Rank[a])
        Rank[a]++;
    num++;
    return true;
}
void rec(int x, int w, vector<vector<pair<int, int>>> &Tree, vector<int> &occ, vector<int> &Querries)
{
    occ[x] = 1;
    if (Querries[x] == 1)
        Querries[x] = w;
    for (int i = 0; i < Tree[x].size(); i++)
    {
        if (occ[Tree[x][i].first] == 1)
            continue;
        rec(Tree[x][i].first, min(w, Tree[x][i].second), Tree, occ, Querries);
    }
}
void linsort(vector<tuple<int, int, int>> &Tab)
{
    vector<vector<tuple<int, int, int>>> temp(100003);
    for (int i = 0; i < Tab.size(); i++)
    {
        temp[get<0>(Tab[i])].push_back(Tab[i]);
    }
    Tab.clear();
    for (int i = 0; i < 100003; i++)
    {
        for (int j = 0; j < temp[i].size(); j++)
        {
            Tab.push_back(temp[i][j]);
        }
    }
}
int main()
{
    int V, E, Q;
    cin >> V >> E >> Q;
    for (int i = 0; i < V; i++)
    {
        UF[i] = i;
        Rank[i] = 0;
    }
    vector<tuple<int, int, int>> Tab;
    for (int i = 0; i < E; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        Tab.push_back({c, a, b});
    }
    linsort(Tab);
}

Compilation message

sightseeing.cpp: In function 'void rec(int, int, std::vector<std::vector<std::pair<int, int> > >&, std::vector<int>&, std::vector<int>&)':
sightseeing.cpp:29:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i = 0; i < Tree[x].size(); i++)
      |                     ~~^~~~~~~~~~~~~~~~
sightseeing.cpp: In function 'void linsort(std::vector<std::tuple<int, int, int> >&)':
sightseeing.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (int i = 0; i < Tab.size(); i++)
      |                     ~~^~~~~~~~~~~~
sightseeing.cpp:46:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         for (int j = 0; j < temp[i].size(); j++)
      |                         ~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 38 ms 6832 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2079 ms 102724 KB Output isn't correct
2 Halted 0 ms 0 KB -