Submission #1020096

#TimeUsernameProblemLanguageResultExecution timeMemory
1020096MrPavlitoMonthly railway pass (LMIO18_menesinis_bilietas)C++17
16 / 100
456 ms144004 KiB
#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 (stderr)

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++;
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...