| # | User | Rating |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3603 |
| 4 | jiangly | 3583 |
| 5 | turmax | 3559 |
| 6 | tourist | 3541 |
| 7 | strapple | 3515 |
| 8 | ksun48 | 3461 |
| 9 | dXqwq | 3436 |
| 10 | Otomachi_Una | 3413 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 157 |
| 2 | adamant | 153 |
| 3 | Um_nik | 147 |
| 4 | Proof_by_QED | 146 |
| 5 | Dominater069 | 145 |
| 6 | errorgorn | 142 |
| 7 | cry | 139 |
| 8 | YuukiS | 135 |
| 9 | TheScrasse | 134 |
| 10 | chromate00 | 133 |
|
0
if(k==1) ans can be YES if one of n,m is 1. Also tha ans is not always no for n==m. |
|
0
I got a tle in D because of using long long instead of int. |
|
0
This is giving a wrong answer can anybody help me why. include <bits/stdc++.h>define loop(i,n) for(int i=0;i<n;i++)using namespace std; class graph{ int n; int m; vector<vector>g; public: graph(int node,int edge){ g.resize(node); n=node; m=edge; } void addedge(int a,int b){ g[a].push_back(b); g[b].push_back(a); } void display(){ loop(i,n){ cout<<i<<"-->"; for(auto x:g[i]){ cout<<x<<" "; } } cout<<endl; } bool bfs(int src,int time,vector&vis){ queue q; q.push(src); time=time+1; if(vis[src]==1){ return 0; } while(!q.empty()&&time){ int sz=q.size(); time--; // cout<<tp<<" "; while(sz--){ int tp=q.front(); vis[tp]=1; q.pop(); for(auto x:g[tp]){ if(vis[x]==0){ q.push(x); } else if(time>0){ return 0; } } } } return 1; } bool check(vector<pair<int,int>>v){ vector vis(n,0); bool ans; for(auto x:v){ int src=x.first; int power=x.second; ans=bfs(src,power,vis); if(ans==0){ //cout<< return 0; } } loop(i,n){ if(vis[i]==0){ //cout<<"yes"<<i<<endl; return 0; } } return 1; } }; int main() { int t; cin>>t; while(t--){ int n,r,m; cin>>n>>r>>m; graph g(n,r); loop(i,r){ int a,b; cin>>a>>b; a--; b--; g.addedge(a,b); } // g.display(); vector<pair<int,int>>v;
loop(i,m){
int a,b;
cin>>a>>b;
a--;
v.push_back(make_pair(a,b));
}// for(auto x:v){ // cout<<x.first<<" "<<x.second<<endl; // } bool ans=g.check(v); if(ans==0){ cout<<"No"<<endl; } else{ cout<<"Yes"<<endl; } } return 0; } |
| Name |
|---|


