結果
問題 | No.1995 CHIKA Road |
ユーザー | YFuka86 |
提出日時 | 2022-07-01 22:15:00 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 6,655 bytes |
コンパイル時間 | 2,539 ms |
コンパイル使用メモリ | 193,236 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-05-04 16:35:59 |
合計ジャッジ時間 | 3,923 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 4 ms
6,944 KB |
testcase_07 | AC | 8 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 25 ms
6,944 KB |
testcase_11 | AC | 30 ms
6,944 KB |
testcase_12 | AC | 31 ms
6,944 KB |
testcase_13 | AC | 11 ms
6,940 KB |
testcase_14 | AC | 12 ms
6,940 KB |
testcase_15 | AC | 27 ms
6,940 KB |
testcase_16 | AC | 5 ms
6,944 KB |
testcase_17 | AC | 18 ms
6,940 KB |
testcase_18 | AC | 28 ms
6,940 KB |
testcase_19 | AC | 29 ms
6,940 KB |
testcase_20 | AC | 15 ms
6,940 KB |
testcase_21 | AC | 15 ms
6,940 KB |
testcase_22 | AC | 26 ms
6,940 KB |
testcase_23 | AC | 9 ms
6,944 KB |
testcase_24 | AC | 23 ms
6,940 KB |
testcase_25 | AC | 6 ms
6,944 KB |
testcase_26 | AC | 11 ms
6,944 KB |
testcase_27 | AC | 22 ms
6,944 KB |
testcase_28 | AC | 15 ms
6,940 KB |
testcase_29 | AC | 27 ms
6,940 KB |
testcase_30 | AC | 5 ms
6,940 KB |
testcase_31 | AC | 4 ms
6,944 KB |
testcase_32 | AC | 8 ms
6,944 KB |
testcase_33 | AC | 23 ms
6,944 KB |
testcase_34 | AC | 4 ms
6,944 KB |
testcase_35 | AC | 11 ms
6,940 KB |
testcase_36 | AC | 11 ms
6,944 KB |
testcase_37 | AC | 27 ms
6,940 KB |
testcase_38 | AC | 18 ms
6,944 KB |
testcase_39 | AC | 4 ms
6,940 KB |
コンパイルメッセージ
main.cpp: In function 'void solve()': main.cpp:99:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 99 | auto [r,l] = rng[i]; | ^
ソースコード
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define rep_r(i,n) for(ll i=(ll)(n)-1;i>=0;i--) #define rep2(i,sta,n) for(ll i=sta;i<(ll)(n);i++) #define rep2_r(i,sta,n) for(ll i=(ll)(n)-1;i>=sta;i--) #define all(v) (v).begin(),(v).end() #define vlin(name,sz,offset) vl name(sz); rep(i,sz){cin>>name[i]; name[i]-=offset;} #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> P; typedef pair<ll, ll> LP; typedef map<ll, ll> LM; typedef tuple<ll, ll, ll> LT; typedef tuple<ll, ll, ll, ll> LT4; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<vvl> v3l; typedef vector<v3l> v4l; typedef vector<v4l> v5l; typedef vector<LP> vlp; typedef vector<vlp> vvlp; typedef vector<string> vs; typedef vector<vs> vvs; typedef vector<ld> vd; typedef vector<vd> vvd; typedef vector<bool> vb; const int INF = numeric_limits<int>::max() / 2 - 1e6; const ll LINF = LLONG_MAX / 2 - 1e6; const double DINF = numeric_limits<double>::infinity(); struct RandGen { using ud = uniform_int_distribution<ll>; mt19937 mt; RandGen() : mt(chrono::steady_clock::now().time_since_epoch().count()) {} ll l(ll a, ll b) { ud d(a, b - 1); return d(mt); } LP lp(ll a, ll b, bool rng = true) { ll x = l(a, b - 1), y = l(rng ? x + 1 : a, b - 1); return {x, y}; } vl vecl(ll l, ll a, ll b) { ud d(a, b - 1); vl ret(l); rep(i, l) ret[i] = d(mt); return ret; } vl vecperm(ll l, ll from = 0) { vl perm(l); iota(all(perm), from); shuffle(perm); return perm; } string str(ll l, string op) { vl fig = vecl(l, 0, op.size()); string s; rep(i, l) s.pb(op[fig[i]]); return s; } string straz(ll l, ll a = 0, ll z = 26) { vl az = vecl(l, a, z); string s; rep(i, l) s.pb('a' + az[i]); return s; } string strnum(ll l, ll zero = 0, ll ten = 10) { vl zt = vecl(l, zero, ten); string s; rep(i, l) s.pb('0' + zt[i]); return s; } void shuffle(vl &a) { std::shuffle(all(a), mt); } }; template<typename T> void coutarray(vector<T>& v, int offset = 0, string sep = " ") { rep(i, v.size()) { if (i > 0) cout << sep; if (offset) cout << v[i] + offset; else cout << v[i]; } cout << "\n"; } template<typename T> void coutmatrix(vector<vector<T>>& v, int offset = 0) { rep(i, v.size()) { coutarray(v[i], offset); } } template<typename T> void coutset(set<T> & s) { for (const auto& a : s) { cout << a << " "; } cout << "\n"; } template<typename K, typename V> void coutmap(map<K, V> & m) { for (const auto& kv : m) { cout << kv.first << ":" << kv.second << " "; } cout << "\n"; } template<typename T, typename S> void coutpair(pair<T, S> & p, string sep = " ") { cout << p.first << ":" << p.second << sep; } template<typename T> void coutbin(T &a, int d) { for (int i = d - 1; i >= 0; i--) cout << ((a >> i) & (T)1); cout << "\n"; } template<typename Q, typename A> void iquery(initializer_list<Q> q, A &a, string str = "? ") { cout << str; vector<Q> v(q); coutarray(v); cout.flush(); cin >> a; } // template<typename Q, typename A> void iquery(initializer_list<Q> q, A &a, string str = "? ") { vector<Q> query(q); RandGen rg; // a = query[0] ? A() : A(); // } template<typename A> void ianswer(A a, string str = "! ") { cout << str << a << "\n"; cout.flush(); } int ceil_pow2(ll n) { int x = 0; while ((1ULL << x) < (unsigned long long)(n)) x++; return x; } int floor_pow2(ll n) { int x = 0; while ((1ULL << (x + 1)) <= (unsigned long long)(n)) x++; return x; } ll digits(ll n) { ll ret = 0; while(n > 0) { ret++; n /= 10; } return ret; } ll POW(ll x, int n) { assert(n >= 0); ll res = 1; for(; n; n >>= 1, x *= x) if(n & 1) res *= x; return res; } ll sqrt_ceil(ll x) { ll l = -1, r = x; while (r - l > 1) { ll m = (l + r) / 2; if (m * m >= x) r = m; else l = m; } return r; } template<typename T, typename S> T ceil(T x, S y) { assert(y); return (y < 0 ? ceil(-x, -y) : (x > 0 ? (x + y - 1) / y : x / y)); } template<typename T, typename S> T floor(T x, S y) { assert(y); return (y < 0 ? floor(-x, -y) : (x > 0 ? x / y : (x - y + 1) / y)); } template<typename T> void uniq(vector<T>&a){ sort(all(a)); a.erase(unique(all(a)), a.end()); } template<typename T> void comp(vector<T>&a){ vector<T> b = a; uniq(b); rep(i, a.size()) a[i] = lower_bound(all(b), a[i]) - b.begin(); } template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1;} return 0; } template<class T> bool chmax(T &a, const T &b) { if (b > a) { a = b; return 1;} return 0; } template<class T> int lbs(vector<T> &a, const T &b) { return lower_bound(all(a), b) - a.begin(); }; template<class T> int ubs(vector<T> &a, const T &b) { return upper_bound(all(a), b) - a.begin(); }; ll binary_search(function<bool(ll)> check, ll ok, ll ng) { assert(check(ok)); while (abs(ok - ng) > 1) { auto x = (ng + ok) / 2; if (check(x)) ok = x; else ng = x; } return ok; } template<class T> vector<T> csum(vector<T> &a) { vl ret(a.size() + 1, 0); rep(i, a.size()) ret[i + 1] = ret[i] + a[i]; return ret; } template<class S> vector<pair<S, int>> RLE(const vector<S> &v) { vector<pair<S, int>> res; for(auto &e : v) if(res.empty() or res.back().first != e) res.emplace_back(e, 1); else res.back().second++; return res; } vector<pair<char, int>> RLE(const string &v) { vector<pair<char, int>> res; for(auto &e : v) if(res.empty() or res.back().first != e) res.emplace_back(e, 1); else res.back().second++; return res; } const string drul = "DRUL"; vl dx = {1, 0, -1, 0}; vl dy = {0, 1, 0, -1}; ll solve(ll N, vl a) { ll ans = -1; return ans; } ll naive(ll N, vl a) { ll ans = 1; return ans; } void compare(bool check = true) { RandGen rg; ll c = 0, loop = 10; while (++c) { if (c % loop == 0) cout << "reached " << c / loop << "loop" << "\n", cout.flush(); ll N = 10; vl a = rg.vecl(N, 1, 1e2); auto s = solve(N, a); auto n = naive(N, a); if (!check || n != s) { cout << c << "times tried" << "\n"; cout << N << "\n"; coutarray(a); cout << "solve: " << s << "\n"; cout << "naive: " << n << "\n"; if (check || (!check && c > loop)) break; } } } void solve() { ll n, m; cin >> n >> m; vlp rng(m); rep(i, m) { ll a, b; cin >> a >> b; rng[i] = {b, a}; } sort(all(rng)); ll ans = (n - 1) * 2; ll cur = 1; rep(i, m) { auto [r,l] = rng[i]; if (l >= cur) { cur = r; ans--; } } cout << ans << "\n"; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout << fixed << setprecision(15); int t = 1; // cin >> t; while (t--) solve(); // while (t--) compare(); }