結果

問題 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,536 ms
コンパイル使用メモリ 265,888 KB
実行使用メモリ 191,464 KB
最終ジャッジ日時 2024-09-15 07:05:22
合計ジャッジ時間 6,617 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 127 ms
48,608 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 522 ms
191,464 KB
testcase_12 AC 13 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 6 ms
5,376 KB
testcase_16 AC 89 ms
36,196 KB
testcase_17 AC 75 ms
27,884 KB
testcase_18 AC 91 ms
36,200 KB
testcase_19 AC 10 ms
5,376 KB
testcase_20 AC 11 ms
5,376 KB
testcase_21 AC 11 ms
5,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 13 ms
5,376 KB
testcase_25 AC 13 ms
5,376 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