結果
問題 | No.1675 Strange Minimum Query |
ユーザー | Focus_Sash |
提出日時 | 2021-09-10 23:18:17 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 281 ms / 2,000 ms |
コード長 | 4,068 bytes |
コンパイル時間 | 7,921 ms |
コンパイル使用メモリ | 274,608 KB |
実行使用メモリ | 38,624 KB |
最終ジャッジ日時 | 2024-06-12 03:58:13 |
合計ジャッジ時間 | 12,659 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 178 ms
17,096 KB |
testcase_04 | AC | 164 ms
20,620 KB |
testcase_05 | AC | 20 ms
12,480 KB |
testcase_06 | AC | 209 ms
19,524 KB |
testcase_07 | AC | 237 ms
24,028 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 71 ms
21,420 KB |
testcase_11 | AC | 23 ms
15,104 KB |
testcase_12 | AC | 77 ms
23,252 KB |
testcase_13 | AC | 138 ms
34,020 KB |
testcase_14 | AC | 162 ms
38,620 KB |
testcase_15 | AC | 173 ms
38,624 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 31 ms
9,404 KB |
testcase_18 | AC | 48 ms
10,800 KB |
testcase_19 | AC | 64 ms
20,068 KB |
testcase_20 | AC | 150 ms
25,176 KB |
testcase_21 | AC | 144 ms
25,588 KB |
testcase_22 | AC | 193 ms
29,356 KB |
testcase_23 | AC | 142 ms
18,060 KB |
testcase_24 | AC | 123 ms
20,368 KB |
testcase_25 | AC | 91 ms
14,124 KB |
testcase_26 | AC | 45 ms
12,368 KB |
testcase_27 | AC | 122 ms
24,924 KB |
testcase_28 | AC | 63 ms
17,932 KB |
testcase_29 | AC | 43 ms
18,304 KB |
testcase_30 | AC | 42 ms
12,544 KB |
testcase_31 | AC | 176 ms
22,960 KB |
testcase_32 | AC | 261 ms
34,112 KB |
testcase_33 | AC | 264 ms
33,860 KB |
testcase_34 | AC | 281 ms
34,112 KB |
testcase_35 | AC | 227 ms
31,416 KB |
testcase_36 | AC | 224 ms
31,348 KB |
ソースコード
#include "bits/stdc++.h" #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; using vl = vector<long long>; using pl = pair<long long, long long>; struct edge {long long to;long long cost;edge(long long t,long long c):to(t),cost(c){}}; using Graph = vector<vector<long long>>; using WGraph = vector<vector<edge>>; constexpr int dx[8]{1,0,-1,0,1,1,-1,-1}; constexpr int dy[8]{0,1,0,-1,1,-1,1,-1}; #define rep(i, n) for(long long (i) = 0; (i) < (n); (i)++) #define reps(i, a, b) for(long long (i) = (a); (i) < (b); (i)++) #define rrep(i, a, b) for(long long (i) = (a); (i) >= (b); (i)--) #define all(v) (v).begin(), (v).end() #define pb push_back #define V vector constexpr long long MOD1 = 1000000007; constexpr long long MOD9 = 998244353; constexpr long long INF = 1000000000; constexpr long long LL_MAX = std::numeric_limits<long long>::max(); long long safe_mod(long long n, long long m){if(n >= 0) {return n % m;} else return (n%m + m)%m;} long long div_ceil(long long a, long long b){return (a + b - 1) / b;} long long pw(long long x,long long n) {ll ret=1;while(n>0){if(n&1){ret=ret*x;}if(n>>=1){x=x*x;}}return ret;} template<typename T> T SUM(const vector<T> &v){T ret{};return(accumulate(v.begin(), v.end(), ret));} template<typename T> T MAX(const vector<T> &v){return *max_element(v.begin(), v.end());} template<typename T> T MIN(const vector<T> &v){return *min_element(v.begin(), v.end());} template<typename T> T pwmod(T x, long long n, long long m) {T ret=1;while(n>0){if(n&1)ret=ret*x%m;x=x*x%m;n>>=1;}return ret%m;} template<typename T> void rsort(vector<T> &v) {sort(v.begin(), v.end(), greater<T>());} template<typename T> bool chmax(T &a, const T& b) {if(a<b){a=b;return true;}return false;} template<typename T> bool chmin(T &a, const T& b) {if(a>b){a=b;return true;}return false;} template<typename T, typename S> pair<T, S> mp(const T &a, const S &b){return make_pair(a, b);} template<typename T> void uniquify(vector<T> &v){sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());} template<typename T,typename S> ostream&operator<<(ostream&os,const pair<T,S>&p){os<<"("<<p.first<<", "<<p.second<<")";return os;} template<typename T,typename S> ostream&operator<<(ostream&os,const map<T,S>&ma){for(auto [a,b]:ma){os<<"("<<a<<", "<<b<<")"<<" ";}return os;} template<typename T> ostream &operator<<(ostream&os,const set<T>&s){os<<"{";for(auto c:s)os<<c<<" ";os<<"}";return os;} template<typename T> ostream &operator<<(ostream&os,const vector<T>&v){os<<"[";for(int i=0;i<v.size();i++){os<<v[i]<<(i==v.size()-1?"":" ");}os<<"]";return os;} template<typename T> vector<int> compress(vector<T> &a){ int n = a.size(); vector<int> ret(n); vector<T> temp = a; sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); for(int i = 0; i < n; i++) ret[i] = lower_bound(a.begin(), a.end(), temp[i]) - a.begin(); return ret; } //#define ONLINE_JUDGE #ifdef ONLINE_JUDGE #define dump(x) true #else #define dump(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl #endif ll op(ll a, ll b){return min(a, b);} ll e(){return INF;} void solve(){ ll n, q; cin >> n >> q; V<vl> L(n+1), R(n+1); V<tuple<ll, ll, ll>> Query(q); rep(i, q){ ll l, r, b; cin >> l >> r >> b; l--; L[l].pb(b); R[r].pb(b); Query[i] = {l, r, b}; } multiset<ll> rest; segtree<ll, op, e> seg(n); rest.insert(1); rep(i, n){ for(ll t : R[i]){ auto iter = rest.find(t); rest.erase(iter); } for(ll t : L[i]) rest.insert(t); seg.set(i, *rest.rbegin()); } rep(i, q){ auto [l, r, b] = Query[i]; if(seg.prod(l, r) != b){ cout << -1 << '\n'; return; } } rep(i, n){ cout << seg.get(i); if(i != n - 1) cout << ' '; } cout << '\n'; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << std::fixed << std::setprecision(15); solve(); return 0; }