Submission #994215

#TimeUsernameProblemLanguageResultExecution timeMemory
994215vjudge1Jail (JOI22_jail)C++17
5 / 100
31 ms1372 KiB
#include <algorithm> #include <iostream> #include <vector> using namespace std; bool solve() { int n; cin >> n; for (int i = 0; i < n - 1; i++) { int u, v; cin >> u >> v; u--; v--; if (u != i || v != i + 1) return false; } int m; cin >> m; vector<pair<int, int>> v(m); for (int i = 0; i < m; i++) { cin >> v[i].first >> v[i].second; } sort(v.begin(), v.end()); for (int i = 0; i < m - 1; i++) { if (v[i].second > v[i + 1].second) return false; } return true; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while (t--) cout << (solve() ? "Yes\n" : "No\n"); }
#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...