답안 #921005

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921005 2024-02-03T08:51:15 Z gelastropod Monthly railway pass (LMIO18_menesinis_bilietas) C++14
16 / 100
584 ms 90608 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int nSets;
vector<int> dsu;
int find(int x)
{
    if (dsu[x] == x) return x;
    return dsu[x] = find(dsu[x]);
}

void join(int a, int b)
{
    a = find(a), b = find(b);
    if (a == b) return;
    dsu[a] = b;
    nSets--;
}

signed main()
{
    int N, M, a, b, ans = 0;
    cin >> N >> M;
    char t;
    for (int i = 0; i < N; i++) dsu.push_back(i);
    nSets = N;
    vector<vector<pair<int, bool>>> adjlist(N, vector<pair<int, bool>>());
    for (int i = 0; i < M; i++)
    {
        cin >> a >> b >> t;
        a--, b--;
        adjlist[a].push_back(pair<int, int>(b, t == 'A'));
        adjlist[b].push_back(pair<int, int>(a, t == 'A'));
        if (t == 'T') join(a, b);
    }
    vector<set<int>> btradjlist(N, set<int>());
    for (int i = 0; i < N; i++)
    {
        for (auto j : adjlist[i])
        {
            if (j.second)
                btradjlist[find(i)].insert(find(j.first));
        }
    }
    for (int i = 0; i < N; i++)
    {
        if (btradjlist[find(i)].size() == nSets - 1) ans++;
    }
    cout << ans << '\n';
}

Compilation message

menesinis_bilietas.cpp: In function 'int main()':
menesinis_bilietas.cpp:48:40: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   48 |         if (btradjlist[find(i)].size() == nSets - 1) ans++;
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 449 ms 48176 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 22 ms 37200 KB Output is correct
5 Correct 1 ms 1372 KB Output is correct
6 Correct 93 ms 10276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 37200 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 4 ms 1372 KB Output is correct
6 Correct 289 ms 47028 KB Output is correct
7 Correct 584 ms 90608 KB Output is correct
8 Correct 11 ms 3544 KB Output is correct
9 Correct 19 ms 5592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 4 ms 1372 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Incorrect 5 ms 860 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Incorrect 5 ms 860 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Incorrect 5 ms 860 KB Output isn't correct
6 Halted 0 ms 0 KB -