結果

問題 No.1605 Matrix Shape
ユーザー
提出日時 2021-07-16 22:03:23
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 814 bytes
コンパイル時間 912 ms
コンパイル使用メモリ 98,160 KB
実行使用メモリ 14,592 KB
最終ジャッジ日時 2024-07-06 09:13:59
合計ジャッジ時間 4,449 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 9
権限があれば一括ダウンロードができます

ソースコード

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