Submission #994200

#TimeUsernameProblemLanguageResultExecution timeMemory
994200vjudge1Jail (JOI22_jail)C++14
5 / 100
29 ms4408 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define pii pair<int, int> #define fi first #define se second const int maxn = 120'000; int n, m; bool cmp(const pii &a, const pii &b) { // } bool solve() { cin >> n; for(int i = 1; i <= n - 1; i++) { int a, b; cin >> a >> b; // do nothing } cin >> m; vector<pii > pairs_left, pairs_right; vector<bool> start_right, end_right, start_left, end_left, spot; start_right = end_right = start_left = end_left = spot = vector<bool> (1 + n, false); for(int i = 1; i <= m; i++) { int a, b; cin >> a >> b; if(a == b) { spot[a] = true; } else if(a < b) { start_right[a] = end_right[b] = true; pairs_right.pb(mp(a, b)); } else { start_left[a] = end_left[b] = true; pairs_left.pb(mp(a, b)); } } int cnt_left = 0, cnt_right = 0; for(int i = 1; i <= n; i++) { if(start_right[i]) { cnt_right++; } if(end_right[i]) { cnt_right--; } if(end_left[i]) { cnt_left++; } if(start_left[i]) { cnt_left--; } if(cnt_left > 0 && cnt_right > 0) { return false; } if(spot[i] && (cnt_left > 0 || cnt_right > 0)) { return false; } } sort(pairs_left.begin(), pairs_left.end()); sort(pairs_right.begin(), pairs_right.end()); int prev = 0; for(pii p : pairs_left) { if(p.se <= prev) { return false; } prev = p.se; } prev = 0; for(pii p : pairs_right) { if(p.se <= prev) { return false; } prev = p.se; } return true; } void reset() { // } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int T = 1; cin >> T; while(T--) { cout << (solve() ? "Yes" : "No") << "\n"; reset(); } }

Compilation message (stderr)

jail.cpp: In function 'bool cmp(const std::pair<int, int>&, const std::pair<int, int>&)':
jail.cpp:17:1: warning: no return statement in function returning non-void [-Wreturn-type]
   17 | }
      | ^
#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...