結果

問題 No.1995 CHIKA Road
ユーザー kabipoyokabipoyo
提出日時 2022-07-01 22:14:55
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 469 ms / 2,000 ms
コード長 1,456 bytes
コンパイル時間 4,555 ms
コンパイル使用メモリ 273,928 KB
実行使用メモリ 40,716 KB
最終ジャッジ日時 2023-08-17 09:45:16
合計ジャッジ時間 10,898 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 16 ms
5,720 KB
testcase_07 AC 65 ms
10,428 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 67 ms
12,200 KB
testcase_11 AC 469 ms
40,716 KB
testcase_12 AC 273 ms
24,948 KB
testcase_13 AC 111 ms
15,768 KB
testcase_14 AC 120 ms
16,228 KB
testcase_15 AC 391 ms
35,984 KB
testcase_16 AC 29 ms
6,860 KB
testcase_17 AC 151 ms
18,324 KB
testcase_18 AC 291 ms
28,208 KB
testcase_19 AC 285 ms
28,412 KB
testcase_20 AC 129 ms
16,824 KB
testcase_21 AC 117 ms
15,716 KB
testcase_22 AC 273 ms
26,772 KB
testcase_23 AC 70 ms
10,744 KB
testcase_24 AC 224 ms
23,864 KB
testcase_25 AC 34 ms
7,576 KB
testcase_26 AC 79 ms
12,068 KB
testcase_27 AC 212 ms
23,156 KB
testcase_28 AC 117 ms
15,808 KB
testcase_29 AC 271 ms
27,308 KB
testcase_30 AC 34 ms
7,576 KB
testcase_31 AC 15 ms
5,492 KB
testcase_32 AC 46 ms
8,664 KB
testcase_33 AC 201 ms
22,780 KB
testcase_34 AC 18 ms
5,428 KB
testcase_35 AC 72 ms
11,652 KB
testcase_36 AC 84 ms
12,880 KB
testcase_37 AC 247 ms
25,496 KB
testcase_38 AC 162 ms
19,584 KB
testcase_39 AC 14 ms
5,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef int64_t lint;
#define rep(i, n) for(int i=0; i<n; i++)
#define repx(i, l, n) for(int i=l; i<n; i++)
#define all(v) v.begin(), v.end()
#define show(x) cout << #x << ": " << x << endl;
#define list(x) cout << #x << ": " << x << "  ";
#define pb push_back
using vi = vector<lint>;
using vvi = vector<vector<lint>>;
template<class T> inline void vin(vector<T>& v) { rep(i, v.size()) cin >> v.at(i); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline void drop(T x) { cout << x << endl; exit(0); }
template<class T> void vout(vector<T> v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; }
constexpr lint LINF = LLONG_MAX/2;
template<class T> map<T, int> coord_comp(set<T> s) {
	int a = 0;
	map<T, int> m;
	for (auto u : s) m[u] = ++a;
	return m;
}

int main() {
	lint N, M;
	cin >> N >> M;
	vi v(M), w(M);
	rep(i, M) cin >> v[i] >> w[i];

	lint a=0, b=0, c=0, x, y, z;
	vvi G(2*M+1);
	set<lint> s;
	rep(i, M) {
		s.insert(v[i]);
		s.insert(w[i]);
	}
	map<lint, int> m = coord_comp(s);
	rep(i, M) {
		G[m[v[i]]].pb(m[w[i]]);
	}
	vi dp(2*M+1);
	rep(i, 2*M) {
		chmax(dp[i+1], dp[i]);
		rep(j, G[i].size()) {
			chmax(dp[G[i][j]], dp[i]+1);
		}
	}
	std::cout << 2*N-2-dp[2*M] << '\n';
}
0