結果
問題 | No.2220 Range Insert & Point Mex |
ユーザー |
![]() |
提出日時 | 2024-07-05 10:50:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,252 bytes |
コンパイル時間 | 763 ms |
コンパイル使用メモリ | 68,392 KB |
最終ジャッジ日時 | 2025-02-22 02:12:02 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 WA * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:44:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 44 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:49:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 49 | scanf("%d%d%d", &l, &r, &a), l--; | ~~~~~^~~~~~~~~~~~~~~~~~~~~~ main.cpp:58:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 58 | scanf("%d", &qn); | ~~~~~^~~~~~~~~~~ main.cpp:62:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 62 | scanf("%d", &x), x--; | ~~~~~^~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 2220.cc: No.2220 Range Insert & Point Mex - yukicoder */ #include<cstdio> #include<vector> #include<set> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 100000; enum { Rmv, Add, Prt }; /* typedef */ using si = set<int>; struct Event { int tp, x, a; Event() {} Event(int _tp, int _x): tp(_tp), x(_x), a(-1) {} Event(int _tp, int _x, int _a): tp(_tp), x(_x), a(_a) {} bool operator<(const Event &e) const { return x < e.x || (x == e.x && tp < e.tp); } }; using vev = vector<Event>; /* global variables */ /* subroutines */ /* main */ int main() { int n; scanf("%d", &n); vev es; for (int i = 0; i < n; i++) { int l, r, a; scanf("%d%d%d", &l, &r, &a), l--; if (a < n) { es.push_back(Event(Rmv, l, a)); es.push_back(Event(Add, r, a)); } } int qn; scanf("%d", &qn); while (qn--) { int x; scanf("%d", &x), x--; es.push_back(Event(Prt, x)); } sort(es.begin(), es.end()); si vs; for (int i = 0; i <= n; i++) vs.insert(i); for (auto &e: es) { if (e.tp == Rmv) vs.erase(e.a); else if (e.tp == Add) vs.insert(e.a); else printf("%d\n", *vs.begin()); } return 0; }