結果

問題 No.274 The Wall
ユーザー shobonvipshobonvip
提出日時 2022-11-14 02:08:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 463 ms / 2,000 ms
コード長 785 bytes
コンパイル時間 4,478 ms
コンパイル使用メモリ 264,520 KB
実行使用メモリ 192,012 KB
最終ジャッジ日時 2023-10-13 09:59:48
合計ジャッジ時間 6,992 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 170 ms
70,424 KB
testcase_04 AC 1 ms
4,372 KB
testcase_05 AC 1 ms
4,372 KB
testcase_06 AC 2 ms
4,368 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 AC 1 ms
4,372 KB
testcase_09 AC 2 ms
4,368 KB
testcase_10 AC 1 ms
4,368 KB
testcase_11 AC 463 ms
192,012 KB
testcase_12 AC 18 ms
4,368 KB
testcase_13 AC 2 ms
4,372 KB
testcase_14 AC 4 ms
4,368 KB
testcase_15 AC 8 ms
4,376 KB
testcase_16 AC 72 ms
37,616 KB
testcase_17 AC 63 ms
27,868 KB
testcase_18 AC 69 ms
35,956 KB
testcase_19 AC 15 ms
4,372 KB
testcase_20 AC 17 ms
4,372 KB
testcase_21 AC 17 ms
4,372 KB
testcase_22 AC 18 ms
4,372 KB
testcase_23 AC 18 ms
4,368 KB
testcase_24 AC 18 ms
4,368 KB
testcase_25 AC 18 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

typedef modint998244353 mint;
typedef long long ll;

int main(){
	int n, m; cin >> n >> m;
	scc_graph scc(2*n);
	vector<int> l(2*n), r(2*n);
	for (int i=0; i<n; i++){
		cin >> l[i] >> r[i];
		l[i+n] = m-1-r[i];
		r[i+n] = m-1-l[i];
	}

	for (int i=0; i<2*n; i++){
		for (int j=i+1; j<2*n; j++){
			if (min(r[i], r[j]) + 1 - max(l[i], l[j]) > 0){
				scc.add_edge(i, (n+j)%(2*n));
				scc.add_edge(j, (n+i)%(2*n));
			}
		}
	}

	vector<vector<int>> g = scc.scc();
	vector<int> moto(2*n);
	for (int i=0; i<g.size(); i++){
		for (int j: g[i]){
			moto[j] = i;
		}
	}

	for (int i=0; i<n; i++){
		if (moto[i] == moto[n+i]){
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
}
0