結果

問題 No.1813 Magical Stones
ユーザー MasKoaTSMasKoaTS
提出日時 2022-01-12 22:41:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,650 bytes
コンパイル時間 4,498 ms
コンパイル使用メモリ 268,616 KB
実行使用メモリ 21,376 KB
最終ジャッジ日時 2024-04-27 13:06:22
合計ジャッジ時間 8,258 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 WA -
testcase_10 AC 2 ms
6,944 KB
testcase_11 WA -
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 15 ms
12,352 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 161 ms
21,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 159 ms
17,272 KB
testcase_21 AC 155 ms
17,256 KB
testcase_22 AC 161 ms
17,268 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 16 ms
6,940 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 2 ms
6,944 KB
testcase_33 AC 2 ms
6,944 KB
testcase_34 AC 7 ms
6,940 KB
testcase_35 AC 21 ms
6,944 KB
testcase_36 AC 3 ms
6,944 KB
testcase_37 AC 45 ms
6,940 KB
testcase_38 AC 17 ms
9,184 KB
testcase_39 AC 89 ms
12,668 KB
testcase_40 AC 4 ms
6,944 KB
testcase_41 AC 7 ms
6,944 KB
testcase_42 AC 22 ms
6,940 KB
testcase_43 AC 12 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//嘘解法

#include <math.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, l, n) for (int i = (l); i < (n); i++)
#define ite(i, a) for(auto& i : a)
#define all(x) x.begin(), x.end()
#define lb lower_bound
#define ub upper_bound
#define lbi(A, x) (ll)(lb(all(A), x) - A.begin())
#define ubi(A, x) (ll)(ub(all(A), x) - A.begin())
using ll = long long;
using Pair = pair<int, int>;
template <class T>	using V = vector<T>;
template <class T>	using VV = V<V<T> >;
const ll INF = 1000000000000000001;
const int inf = 1001001001;
const ll mod = 1000000007;
const ll MOD = 998244353;
template <class T>  inline V<T> getList(int n) { V<T> res(n); rep(i, 0, n) { cin >> res[i]; }return res; }
template <class T>  inline VV<T> getGrid(int m, int n) { VV<T> res(m, V<T>(n)); rep(i, 0, m) { res[i] = getList<T>(n); }return res; }
inline V<int> dtois(string& s) { V<int> vec = {}; for (auto& e : s) { vec.push_back(e - '0'); } return vec; }


int main(void) {
	int n, m;	cin >> n >> m;
	VV<int> route(n, V<int>(0));
	scc_graph g(n);

	rep(i, 0, m) {
		int a, b;	cin >> a >> b;	a--;	b--;
		route[a].push_back(b);
		g.add_edge(a, b);
	}

	VV<int> scc = g.scc();
	if (scc.size() == 1) {
		cout << 0 << endl;
		return 0;
	}
	V<int> group(n);
	rep(i, 0, scc.size()) {
		ite(p, scc[i]) {
			group[p] = i;
		}
	}

	V<int> source(scc.size(), 1);	V<int> sink(scc.size(), 1);
	rep(i, 0, n) {
		ite(j, route[i]) {
			int s = group[i];	int t = group[j];
			sink[s] = source[t] = 0;
		}
	}

	int s = 0, t = 0;
	ite(i, source) {
		s += i;
	}
	ite(i, sink) {
		t += i;
	}

	cout << max(s, t) << endl;
	return 0;
}
0