結果
| 問題 |
No.1605 Matrix Shape
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-16 22:02:04 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 801 bytes |
| コンパイル時間 | 871 ms |
| コンパイル使用メモリ | 99,468 KB |
| 実行使用メモリ | 14,592 KB |
| 最終ジャッジ日時 | 2024-07-06 09:11:55 |
| 合計ジャッジ時間 | 5,296 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 WA * 4 |
ソースコード
#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);
if (r[h] == 0) {
l[h]++;
}
else {
r[h]--;
}
if (l[w] == 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;
}
}