結果

問題 No.274 The Wall
ユーザー shobonvipshobonvip
提出日時 2022-11-14 02:06:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 781 bytes
コンパイル時間 4,268 ms
コンパイル使用メモリ 265,368 KB
実行使用メモリ 192,312 KB
最終ジャッジ日時 2023-10-13 09:58:48
合計ジャッジ時間 6,563 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 94 ms
48,888 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 377 ms
192,312 KB
testcase_12 AC 12 ms
4,352 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 6 ms
4,352 KB
testcase_16 AC 70 ms
37,364 KB
testcase_17 AC 61 ms
27,744 KB
testcase_18 AC 68 ms
37,364 KB
testcase_19 AC 10 ms
4,348 KB
testcase_20 AC 11 ms
4,352 KB
testcase_21 AC 11 ms
4,352 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 12 ms
4,352 KB
testcase_25 AC 12 ms
4,348 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]) - 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