Submission #872111

#TimeUsernameProblemLanguageResultExecution timeMemory
872111mgl_diamondJail (JOI22_jail)C++17
0 / 100
6 ms3420 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; #define foru(i, l, r) for(int i=(l); i<=(r); ++i) #define ford(i, l, r) for(int i=(l); i>=(r); --i) #define fore(x, v) for(auto &x : v) #define all(x) (x).begin(), (x).end() #define sz(x) (int)x.size() #define file "input" template<class T> bool maximize(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> bool minimize(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } void setIO() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(file".inp", "r")) { freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout); } } const int N = 120002; int q, n, m; vector<int> graph[N]; int main() { setIO(); cin >> q; while (q--) { cin >> n; foru(i, 1, n) { graph[i].clear(); } foru(i, 2, n) { int u, v; cin >> u >> v; graph[u].push_back(v); graph[v].push_back(u); } vector<ii> pos[2]; int mn = N, mx = -N; cin >> m; foru(i, 1, m) { int u, v; cin >> u >> v; pos[u > v].emplace_back(u, v); if (u > v) minimize(mn, v); if (u < v) maximize(mx, v); } sort(all(pos[0])); sort(all(pos[1]), greater<ii>()); // fore(x, pos[0]) cout << x.first << " " << x.second << "\n"; bool can = 1; if (mn < mx) can = 0; foru(i, 0, sz(pos[0])-2) if (pos[0][i].second > pos[0][i+1].second) can = 0; foru(i, 0, sz(pos[1])-2) if (pos[1][i].second < pos[1][i+1].second) can = 0; cout << (can ? "Yes\n" : "No\n"); } }

Compilation message (stderr)

jail.cpp: In function 'void setIO()':
jail.cpp:21:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     freopen(file".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
jail.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     freopen(file".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...