제출 #417292

#제출 시각아이디문제언어결과실행 시간메모리
417292maomao90Event Hopping 2 (JOI21_event2)C++17
0 / 100
140 ms19840 KiB
#include <bits/stdc++.h> using namespace std; template <class T> inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;} template <class T> inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;} #define REP(i, s, e) for (int i = s; i < e; i++) #define RREP(i, s, e) for (int i = s; i >= e; i--) typedef long long ll; typedef long double ld; #define MP make_pair #define FI first #define SE second typedef pair<int, int> ii; typedef pair<ll, ll> pll; #define MT make_tuple typedef tuple<int, int, int> iii; #define ALL(_a) _a.begin(), _a.end() #define pb emplace_back typedef vector<int> vi; typedef vector<ll> vll; typedef vector<ii> vii; #define INF 1000000005 #define LINF 1000000000000000005 #define MOD 1000000007 #define MAXN 200005 int n, k; ii lr[MAXN]; vi events; set<int> st; map<int, int> mp; int d[MAXN]; vi ans; int v[MAXN * 4]; void update(int p, int x, int u, int lo, int hi) { int mid = lo + hi >> 1; if (lo == hi) { v[u] = x; return; } int lc = u * 2, rc = u * 2 + 1; if (p <= mid) update(p, x, lc, lo, mid); else update(p, x, rc, mid + 1, hi); v[u] = max(v[lc], v[rc]); } void update(int p, int x) { update(p, x, 1, 0, 2 * n); } int query(int s, int e, int u, int lo, int hi) { if (lo >= s && hi <= e) { return v[u]; } int mid = lo + hi >> 1; int lc = u * 2, rc = u * 2 + 1; if (e <= mid) return query(s, e, lc, lo, mid); else if (s > mid) return query(s, e, rc, mid + 1, hi); else return max(query(s, e, lc, lo, mid), query(s, e, rc, mid + 1, hi)); } int query(int s, int e) { return query(s, e, 1, 0, 2 * n); } int main() { scanf("%d%d", &n, &k); REP (i, 0, n) { scanf("%d%d", &lr[i].FI, &lr[i].SE); st.insert(lr[i].FI); st.insert(lr[i].SE); } int ptr = 0; for (auto i : st) { mp[i] = ptr++; } REP (i, 0, n) { lr[i].FI = mp[lr[i].FI]; lr[i].SE = mp[lr[i].SE]; } REP (i, 0, 1 << n) { if (__builtin_popcount(i) != k) continue; vector<iii> tmp; REP (j, 0, n) { if (i & (1 << j)) { tmp.pb(lr[j].FI, lr[j].SE, j); } } sort(ALL(tmp)); bool pos = 1; REP (j, 1, tmp.size()) { auto [l, r, id] = tmp[j]; auto [pl, pr, pid] = tmp[j - 1]; if (pr > l) { pos = 0; break; } } if (pos) { for (auto [l, r, id] : tmp) { printf("%d\n", id + 1); } return 0; } } printf("-1\n"); return 0; } /* 4 2 1 4 3 5 4 9 7 10 12 3 1 4 1 8 1 3 1 2 1 4 3 8 3 5 3 9 6 11 6 10 6 12 6 7 6 1 1 7 2 5 2 4 4 8 4 7 8 9 6 4 1 3 1 2 2 4 4 5 5 6 6 7 */

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

event2.cpp: In function 'void update(int, int, int, int, int)':
event2.cpp:40:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   40 |  int mid = lo + hi >> 1;
      |            ~~~^~~~
event2.cpp: In function 'int query(int, int, int, int, int)':
event2.cpp:57:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   57 |  int mid = lo + hi >> 1;
      |            ~~~^~~~
event2.cpp: In function 'int main()':
event2.cpp:8:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define REP(i, s, e) for (int i = s; i < e; i++)
......
   92 |   REP (j, 1, tmp.size()) {
      |        ~~~~~~~~~~~~~~~~                 
event2.cpp:92:3: note: in expansion of macro 'REP'
   92 |   REP (j, 1, tmp.size()) {
      |   ^~~
event2.cpp:68:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |  scanf("%d%d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~
event2.cpp:70:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |   scanf("%d%d", &lr[i].FI, &lr[i].SE);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...