Submission #951940

#TimeUsernameProblemLanguageResultExecution timeMemory
951940ting39Jail (JOI22_jail)C++17
5 / 100
130 ms13452 KiB
#include<bits/stdc++.h> #define pii pair<int,int> #define F first #define S second #define int long long using namespace std; signed main(){ int t; cin>>t; while(t--){ int n; cin>>n; vector<vector<int>> g(n); for(int i=0;i<n-1;i++){ int a,b; cin>>a>>b; a--; b--; if(a!=i||b!=i+1) return 0; g[a].push_back(b); g[b].push_back(a); } int m; cin>>m; vector<pii> s(m),t(m); for(int i=0;i<m;i++){ int a,b; cin>>a>>b; s[i]={a,i}; t[i]={b,i}; } sort(s.begin(),s.end()); sort(t.begin(),t.end()); int ans=1; for(int i=0;i<m;i++){ if(s[i].S!=t[i].S) ans=0; } if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl; } }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...