답안 #1020096

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1020096 2024-07-11T14:34:05 Z MrPavlito Monthly railway pass (LMIO18_menesinis_bilietas) C++17
16 / 100
456 ms 144004 KB
#include <bits/stdc++.h>
//#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define sc second
#define endl "\n"
#define pii pair<int,int>

using namespace std;

const int MAXN = 5e5+5;
const int mod7 = 1e9+7;
const long long inf = 1e18;
int n,m;

struct grana{int a,b;char c;};

vector<vector<pii>> graf(MAXN);
vector<unordered_set<int>> compressGraf(MAXN);
int whichCMP[MAXN];
bool visited[MAXN];

void dfs(int nod, int cmp)
{
    visited[nod] = 1;
    whichCMP[nod] = cmp;
    for(auto x: graf[nod])
    {
        if(x.sc == 1)continue;
        if(!visited[x.fi])dfs(x.fi,cmp);
    }
}


signed main()
{
    ios_base::sync_with_stdio(false),cin.tie(0), cout.tie(0);
    int tt=1;
    //cin >> tt;
    while(tt--)
    {
        cin >> n >> m;
        vector<grana> svegrane;
        for(int i=0; i<m; i++)
        {
            int a,b;char c;
            cin >> a >> b >> c;
            if(c=='T')
            {
                graf[a].pb(mp(b,0));
                graf[b].pb(mp(a,0));
            }
            else
            {
                graf[a].pb(mp(b,1));
                graf[b].pb(mp(a,1));
            }
            svegrane.pb({a,b,c});
        }
        int c = 0;
        for(int i=1; i<=n; i++)
        {
            if(!visited[i])
            {
                c++;
                dfs(i,c);
            }
        }
        for(auto x: svegrane)
        {
            if(x.c == 'T')continue;
            compressGraf[whichCMP[x.a]].insert(whichCMP[x.b]);
            compressGraf[whichCMP[x.b]].insert(whichCMP[x.a]);
        }
        int rez = 0;
        for(int i=1; i<=n; i++)
        {
            if(compressGraf[whichCMP[i]].size() == c-1)rez++;
        }
        cout << rez << endl;
    }

}

Compilation message

menesinis_bilietas.cpp: In function 'int main()':
menesinis_bilietas.cpp:80:49: warning: comparison of integer expressions of different signedness: 'std::unordered_set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   80 |             if(compressGraf[whichCMP[i]].size() == c-1)rez++;
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 190 ms 74960 KB Output is correct
2 Correct 16 ms 39516 KB Output is correct
3 Correct 13 ms 39516 KB Output is correct
4 Correct 15 ms 41820 KB Output is correct
5 Correct 12 ms 39516 KB Output is correct
6 Correct 52 ms 49412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 41820 KB Output is correct
2 Correct 12 ms 39516 KB Output is correct
3 Correct 13 ms 39512 KB Output is correct
4 Correct 14 ms 39516 KB Output is correct
5 Correct 17 ms 40540 KB Output is correct
6 Correct 355 ms 85240 KB Output is correct
7 Correct 456 ms 144004 KB Output is correct
8 Correct 26 ms 43352 KB Output is correct
9 Correct 30 ms 44948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 39516 KB Output is correct
2 Correct 13 ms 39516 KB Output is correct
3 Correct 13 ms 39512 KB Output is correct
4 Correct 14 ms 39516 KB Output is correct
5 Correct 17 ms 40540 KB Output is correct
6 Correct 13 ms 39516 KB Output is correct
7 Correct 14 ms 39516 KB Output is correct
8 Correct 13 ms 39772 KB Output is correct
9 Correct 13 ms 39676 KB Output is correct
10 Incorrect 21 ms 40020 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 39516 KB Output is correct
2 Correct 14 ms 39516 KB Output is correct
3 Correct 13 ms 39772 KB Output is correct
4 Correct 13 ms 39676 KB Output is correct
5 Incorrect 21 ms 40020 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 39516 KB Output is correct
2 Correct 14 ms 39516 KB Output is correct
3 Correct 13 ms 39772 KB Output is correct
4 Correct 13 ms 39676 KB Output is correct
5 Incorrect 21 ms 40020 KB Output isn't correct
6 Halted 0 ms 0 KB -