結果
問題 | No.1675 Strange Minimum Query |
ユーザー | ebi_fly |
提出日時 | 2021-09-10 21:40:57 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,368 bytes |
コンパイル時間 | 3,541 ms |
コンパイル使用メモリ | 202,568 KB |
実行使用メモリ | 29,536 KB |
最終ジャッジ日時 | 2024-06-11 23:00:18 |
合計ジャッジ時間 | 9,693 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 163 ms
12,160 KB |
testcase_04 | AC | 139 ms
14,592 KB |
testcase_05 | AC | 12 ms
8,448 KB |
testcase_06 | AC | 177 ms
13,568 KB |
testcase_07 | AC | 193 ms
16,640 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 150 ms
29,536 KB |
testcase_15 | WA | - |
testcase_16 | AC | 2 ms
6,944 KB |
testcase_17 | WA | - |
testcase_18 | AC | 41 ms
8,320 KB |
testcase_19 | AC | 58 ms
13,532 KB |
testcase_20 | AC | 117 ms
17,408 KB |
testcase_21 | AC | 112 ms
17,976 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 45 ms
12,288 KB |
testcase_29 | AC | 32 ms
11,556 KB |
testcase_30 | AC | 37 ms
9,216 KB |
testcase_31 | WA | - |
testcase_32 | AC | 234 ms
23,396 KB |
testcase_33 | AC | 214 ms
23,408 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
ソースコード
#include <iostream> #include <algorithm> #include <utility> #include <string> #include <vector> #include <set> #include <stack> #include <queue> #include <map> #include <math.h> #include <string.h> #include <iomanip> #include <numeric> #include <cstdlib> #include <cstdint> #include <cmath> #include <functional> #include <limits> #include <cassert> #include <bitset> #include <chrono> #include <random> #include <memory> #include <atcoder/all> /* macro */ #define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++) #define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--) #define Rep(i, a, n) for (i64 i = (i64)(a); i< (i64)(n); i++) #define RRep(i, a, n) for (i64 i = ((i64)(n-i64(1))); i>=(i64)(a); i--) #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define Bit(n) (1LL<<(n)) /* macro end */ /* template */ namespace ebi { #ifdef LOCAL #define debug(...) \ std::cerr << "LINE: " << __LINE__ << " [" << #__VA_ARGS__ << "]:", \ debug_out(__VA_ARGS__) #else #define debug(...) #endif void debug_out() { std::cerr << std::endl; } template <typename Head, typename... Tail> void debug_out(Head h, Tail... t) { std::cerr << " " << h; if (sizeof...(t) > 0) std::cout << " :"; debug_out(t...); } template <typename T1, typename T2> std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) { return os << pa.first << " " << pa.second; } template <typename T> std::ostream& operator<<(std::ostream& os, std::vector<T> vec) { for (std::size_t i = 0; i < vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : " "); return os; } std::ostream& operator<<(std::ostream& os, atcoder::modint1000000007 a){ return os << a.val(); } std::ostream& operator<<(std::ostream& os, atcoder::modint998244353 a){ return os << a.val(); } using size_t = std::size_t; using i32 = std::int32_t; using u32 = std::uint32_t; using i64 = long long; using u64 = unsigned long long; template<class T> void fill(std::vector<T> &v) { for(T &e: v) std::cin >> e; } template<class T> struct Edge { int to; T cost; Edge(int to, T cost) : to(to), cost(cost) { } }; template<class T> std::ostream& operator<<(std::ostream& os, Edge<T> e) { return os << "[" << e.to << ", " << e.cost << "] "; } template<class T> struct Graph : std::vector<std::vector<Edge<T>>> { using std::vector<std::vector<Edge<T>>>::vector; void add_edge(int u, int v, T w, bool directed = false) { (*this)[u].emplace_back(v, w); if(directed) return; (*this)[v].emplace_back(u, w); } }; struct graph : std::vector<std::vector<int>> { using std::vector<std::vector<int>>::vector; void add_edge(int u, int v, bool directed = false) { (*this)[u].emplace_back(v); if(directed) return; (*this)[v].emplace_back(u); } }; template <class T> inline bool chmin(T &a, T b) { if (a > b){ a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b){ a = b; return true; } return false; } template <class T> T gcd(T a, T b){ if( b==0 ) return a; else return gcd(b, a%b); } template <class T> T lcm(T a, T b) { return (a*b)/gcd(a,b); } template<class T> T pow(T x, i64 n) { T res = 1; while(n>0){ if(n&1) res = res *x; x = x*x; n>>=1; } return res; } template<class T> T mod_pow(T x, i64 n, i64 mod) { T res = 1; while(n > 0) { if(n & 1) res = (res * x)%mod; x = (x*x)%mod; n >>= 1; } return res; } template<class T> T scan() { T val; std::cin >> val; return val; } constexpr i64 LNF = std::numeric_limits<i64>::max()/4; constexpr int INF = std::numeric_limits<int>::max()/4; const long double PI = acos(-1); const std::vector<int> dy = {1,0,-1,0,1,1,-1,-1}; const std::vector<int> dx = {0,1,0,-1,1,-1,1,-1}; } /* template end */ namespace ebi { using pii = std::pair<int,int>; using ld = long double; using mint = atcoder::modint1000000007; int op(int a, int b) { return a < b ? a : b; } int e() { return INF; } void main_() { int n,q; std::cin >> n >> q; std::vector ret(n+1, std::vector<int>()); std::vector<std::pair<int,int>> lr(q); std::vector<int> b(q); rep(i,0,q) { auto &[l, r] = lr[i]; std::cin >> l >> r >> b[i]; l--; ret[l].emplace_back(b[i]); ret[r].emplace_back(-b[i]); } std::vector<int> ans(n); std::multiset<int> set; set.insert(1); rep(i,0,n) { for(auto val: ret[i]) { if(val < 0) { set.erase(set.find(-val)); } else { set.insert(val); } } ans[i] = *set.rbegin(); } atcoder::segtree<int, op, e> seg(ans); rep(i,0,q) { auto [l, r] = lr[i]; if(seg.prod(l, r) != b[i]) { std::cout << "-1\n"; return; } } rep(i,0,n) { std::cout << ans[i] << " \n"[i == n-1]; } } } int main() { std::cout << std::fixed << std::setprecision(15); std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int t = 1; while(t--) { ebi::main_(); } return 0; }