제출 #1272461

#제출 시각아이디문제언어결과실행 시간메모리
1272461wedonttalkanymoreMatryoshka (JOI16_matryoshka)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int long long #define pii pair<ll, ll> #define fi first #define se second const ll N = 2e5 + 5, inf = 1e18, mod = 1e9 + 7, block = 320, lim = 19; int n; pii a[N]; int q; vector <pii> have; bool cmp(pii x, pii y) { if (x.fi == y.fi) return x.se > y.se; return x.fi > y.fi; } void solve() { sort(have.begin(), have.end(), cmp); multiset <int> s; for (int i = 0; i < have.size();) { int l = i; multiset <int> news; while(l < have.size() && have[l].fi == have[i].fi) { auto it = s.upper_bound(have[l].se); if (it != s.end()) { s.erase(it); news.insert(have[l].se); } else news.insert(have[l].se); l++; } for (auto x : news) s.insert(x); i = l; } cout << s.size() << '\n'; } signed main() { ios::sync_with_stdio(false); cin.tie(0); if (fopen(".inp", "r")) { freopen(".inp", "r", stdin); freopen(".out", "w", stdout); } cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i].fi >> a[i].se; } cin >> q; for (int i = 1; i <= q; i++) { int x, y; cin >> x >> y; have.clear(); for (int j = 1; j <= n; j++) { if (a[j].fi >= x && a[j].se <= y) { have.push_back({a[j].fi, a[j].se}); } } solve(); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

matryoshka.cpp: In function 'int main()':
matryoshka.cpp:48:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |         freopen(".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
matryoshka.cpp:49:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |         freopen(".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...