답안 #642988

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
642988 2022-09-21T02:26:05 Z CyberSleeper Monthly railway pass (LMIO18_menesinis_bilietas) C++17
16 / 100
496 ms 109028 KB
#include <bits/stdc++.h>
#define fastio      ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define debug(x)    cout << "Line " << __LINE__ << ", " << #x << " is " << x << endl
#define all(x)      x.begin(), x.end()
#define fi          first
#define se          second
#define mp          make_pair
#define pb          push_back
#define ll          long long
#define ull         unsigned long long
#define pll         pair<ll, ll>
#define pii         pair<ll, ll>
#define ld          long double
#define nl          '\n'
#define tb          '\t'
#define sp          ' '
#define sqr(x)      (x)*(x)
#define arr3        array<ll, 3>
#define arr4        array<ll, 4>
using namespace std;
 
const ll MX=500007, MOD=1000000007, BLOCK=333, INF=1e9+7, LG=62, KEY1=177013, KEY2=353707;
const ll INFF=1000000000000000007;
const ld ERR=1e-6;

int N, M, group[MX], sz[MX], cnt, ans;
vector<int> bus[MX], tr[MX];
set<int> adj[MX];

void DFS(int x){
    group[x]=cnt;
    sz[cnt]++;
    for(int i:tr[x]){
        if(group[i])
            continue;
        DFS(i);
    }
}

int main(){
    fastio;
    cin >> N >> M;
    for(int i=0; i<M; i++){
        int u, v;
        char w;
        cin >> u >> v >> w;
        if(u == v)
            continue;
        if(w == 'A'){
            bus[u].pb(v);
            bus[v].pb(u);
        }else{
            tr[u].pb(v);
            tr[v].pb(u);
        }
    }
    for(int i=1; i<=N; i++){
        if(!group[i]){
            cnt++;
            DFS(i);
        }
    }
    for(int i=1; i<=N; i++){
        for(int j:bus[i]){
            adj[group[i]].insert(group[j]);
        }
    }
    for(int i=1; i<=N; i++){
        if(adj[i].size()==cnt-1)
            ans+=sz[i];
    }
    cout << ans << nl;
}

Compilation message

menesinis_bilietas.cpp: In function 'int main()':
menesinis_bilietas.cpp:69:25: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   69 |         if(adj[i].size()==cnt-1)
      |            ~~~~~~~~~~~~~^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 327 ms 70432 KB Output is correct
2 Correct 25 ms 47276 KB Output is correct
3 Correct 22 ms 47316 KB Output is correct
4 Correct 29 ms 50908 KB Output is correct
5 Correct 23 ms 47308 KB Output is correct
6 Correct 65 ms 52360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 50908 KB Output is correct
2 Correct 23 ms 47308 KB Output is correct
3 Correct 23 ms 47244 KB Output is correct
4 Correct 23 ms 47420 KB Output is correct
5 Correct 25 ms 48084 KB Output is correct
6 Correct 270 ms 86832 KB Output is correct
7 Correct 496 ms 109028 KB Output is correct
8 Correct 39 ms 49488 KB Output is correct
9 Correct 44 ms 50912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 47276 KB Output is correct
2 Correct 22 ms 47316 KB Output is correct
3 Correct 23 ms 47244 KB Output is correct
4 Correct 23 ms 47420 KB Output is correct
5 Correct 25 ms 48084 KB Output is correct
6 Correct 23 ms 47172 KB Output is correct
7 Correct 23 ms 47232 KB Output is correct
8 Correct 23 ms 47316 KB Output is correct
9 Correct 24 ms 47428 KB Output is correct
10 Incorrect 25 ms 47572 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 47172 KB Output is correct
2 Correct 23 ms 47232 KB Output is correct
3 Correct 23 ms 47316 KB Output is correct
4 Correct 24 ms 47428 KB Output is correct
5 Incorrect 25 ms 47572 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 47172 KB Output is correct
2 Correct 23 ms 47232 KB Output is correct
3 Correct 23 ms 47316 KB Output is correct
4 Correct 24 ms 47428 KB Output is correct
5 Incorrect 25 ms 47572 KB Output isn't correct
6 Halted 0 ms 0 KB -