結果

問題 No.1605 Matrix Shape
ユーザー 夜
提出日時 2021-07-16 22:03:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 814 bytes
コンパイル時間 780 ms
コンパイル使用メモリ 97,348 KB
実行使用メモリ 14,372 KB
最終ジャッジ日時 2023-09-20 13:59:31
合計ジャッジ時間 5,451 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 237 ms
14,320 KB
testcase_20 AC 181 ms
8,888 KB
testcase_21 AC 176 ms
8,800 KB
testcase_22 WA -
testcase_23 AC 229 ms
14,308 KB
testcase_24 AC 239 ms
14,324 KB
testcase_25 AC 85 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 85 ms
4,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 181 ms
8,832 KB
testcase_31 WA -
testcase_32 AC 153 ms
6,068 KB
testcase_33 WA -
testcase_34 AC 102 ms
4,376 KB
testcase_35 AC 184 ms
12,172 KB
testcase_36 AC 97 ms
8,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int l[200020] = {}, r[200020] = {};
set<int> st;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int h, w;
		cin >> h >> w;
		st.insert(h);
		int m = l[w];
		if (r[h] == 0) {
			l[h]++;
		}
		else {
			r[h]--;
		}
		if (m == 0) {
			r[w]++;
		}
		else {
			l[w]--;
		}
	}
	int l1 = 0, r1 = 0;
	for (int i = 1; i <= 200000; i++) {
		l1 += l[i];
		r1 += r[i];
	}
	if (l1 == 0 && r1 == 0) {
		cout << st.size() << endl;
	}
	else if (l1 == 1 && r1 == 1) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
}
0