Submission #382162

#TimeUsernameProblemLanguageResultExecution timeMemory
382162fadi57Monthly railway pass (LMIO18_menesinis_bilietas)C++14
10 / 100
1916 ms212260 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mx=5e6+10; const int mod= 1e9+7 ; const ll inf=1e18; //***while there is life there is hope //int a[mx]; int n,m; vector<pair<int,int>>adj[mx]; int vis[mx]; void dfs(int i,int par){ vis[i]=1; for(auto it:adj[i]){ if(it.first==par||vis[it.first]){continue;} dfs(it.first,i); } return; } int ist(char x){ return (x=='A'); } map<int,set<int>>mp; int main() { cin>>n>>m; int sec=0; for(int i=0;i<m;i++){ int x,y;char t; cin>>x>>y>>t; mp[x].insert(y);mp[y].insert(x); if(ist(t)){ sec=1; } adj[x].push_back({y,ist(t)}); adj[y].push_back({x,ist(t)}); } dfs(1,-1); int ok=1; for(int i=1;i<=n;i++){ if(vis[i]==0){ok=0;} } if(sec==0){ if(ok){ cout<<n; }else{ cout<<0; }}else{ int ok=1;int ans=0; for(int i=1;i<=n;i++){ if(mp[i].size()>n-1){ans++;} }cout<<ans; } }

Compilation message (stderr)

menesinis_bilietas.cpp: In function 'int main()':
menesinis_bilietas.cpp:61:20: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   61 |     if(mp[i].size()>n-1){ans++;}
      |        ~~~~~~~~~~~~^~~~
menesinis_bilietas.cpp:59:5: warning: unused variable 'ok' [-Wunused-variable]
   59 | int ok=1;int ans=0;
      |     ^~
#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...