結果
問題 | No.1675 Strange Minimum Query |
ユーザー | sata shun |
提出日時 | 2021-09-10 21:31:18 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,437 bytes |
コンパイル時間 | 2,603 ms |
コンパイル使用メモリ | 220,724 KB |
実行使用メモリ | 30,316 KB |
最終ジャッジ日時 | 2024-06-11 22:37:21 |
合計ジャッジ時間 | 11,580 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 243 ms
13,960 KB |
testcase_04 | AC | 218 ms
14,936 KB |
testcase_05 | AC | 17 ms
8,320 KB |
testcase_06 | AC | 307 ms
15,772 KB |
testcase_07 | AC | 354 ms
17,508 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 156 ms
25,668 KB |
testcase_14 | AC | 176 ms
30,316 KB |
testcase_15 | AC | 193 ms
28,216 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 32 ms
7,296 KB |
testcase_18 | AC | 50 ms
7,936 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 213 ms
20,932 KB |
testcase_23 | AC | 159 ms
13,904 KB |
testcase_24 | AC | 144 ms
14,296 KB |
testcase_25 | AC | 101 ms
10,776 KB |
testcase_26 | WA | - |
testcase_27 | AC | 138 ms
17,400 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 203 ms
16,684 KB |
testcase_32 | AC | 292 ms
24,852 KB |
testcase_33 | AC | 282 ms
24,632 KB |
testcase_34 | AC | 295 ms
24,864 KB |
testcase_35 | AC | 254 ms
20,112 KB |
testcase_36 | AC | 248 ms
20,112 KB |
ソースコード
//#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; template <class T> V<T> make_vec(size_t a) { return V<T>(a); } template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) { return V<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); } #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define rep(i, n) rep2(i, 0, n) #define rep2(i, m, n) for (int i = m; i < (n); i++) #define per(i, b) per2(i, 0, b) #define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--) #define ALL(c) (c).begin(), (c).end() #define SZ(x) ((int)(x).size()) constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } template <class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; } template <class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; } template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << "(" << p.first << "," << p.second << ")"; return os; } template <class T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "{"; rep(i, v.size()) { if (i) os << ","; os << v[i]; } os << "}"; return os; } #ifdef LOCAL void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...); } #define debug(...) \ cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl #else #define debug(...) (void(0)) #define dump(x) (void(0)) #endif template <class T> void print(T x, int suc = 1) { cout << x; if (suc == 1) cout << "\n"; else if (suc == 2) cout << " "; } template <class T> void print(const vector<T>& v, int suc = 1) { for (int i = 0; i < v.size(); ++i) print(v[i], i == int(v.size()) - 1 ? suc : 2); } // index of root = 1 template <class U> struct segtree { using T = typename U::T; int sz; V<T> dat; segtree() {} segtree(int n) { sz = 1; while (sz < n) sz <<= 1; dat.assign(sz * 2, U::id()); } segtree(const V<T>& a) { int n = a.size(); sz = 1; while (sz < n) sz <<= 1; dat.assign(sz * 2, U::id()); for (int i = 0; i < n; ++i) { dat[sz + i] = a[i]; } for (int i = sz - 1; i >= 1; --i) { upd(i); } } void upd(int p) { dat[p] = U::op(dat[p << 1], dat[p << 1 | 1]); } void build() { for (int i = sz - 1; i > 0; --i) { dat[i] = U::op(dat[i << 1], dat[i << 1 | 1]); } } void modify(int p, T v) { p += sz; dat[p] = v; while (p >>= 1) { dat[p] = U::op(dat[p << 1], dat[p << 1 | 1]); } } //[l, r) T query(int l, int r) { T lval = U::id(), rval = U::id(); for (l += sz, r += sz; l < r; l >>= 1, r >>= 1) { if (l & 1) lval = U::op(lval, dat[l++]); if (r & 1) rval = U::op(dat[--r], rval); } return U::op(lval, rval); } }; // modify only U for use constexpr int INF = TEN(9) + 10; struct U { using T = int; static T id() { return INF; } static T op(const T& a, const T& b) { return min(a, b); } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N, Q; cin >> N >> Q; VV<pii> ev(N + 1); V<tuple<int, int, int>> vec; rep(i, Q) { int l, r, x; cin >> l >> r >> x; --l; ev[l].eb(-1, x); ev[r].eb(1, x); vec.eb(l, r, x); } multiset<int> st; st.insert(0); V<int> A(N); rep(i, N) { sort(ALL(ev[i])); for (auto p : ev[i]) { if (p.fi == -1) { st.insert(p.se); } else { st.erase(st.find(p.se)); } } A[i] = *st.rbegin(); } segtree<U> seg(A); bool ok = 1; for (auto& [l, r, x] : vec) { if (seg.query(l, r) != x) { ok = 0; } } if (ok) { print(A); } else { cout << -1 << endl; } return 0; }