結果
| 問題 |
No.1605 Matrix Shape
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-16 21:41:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 682 bytes |
| コンパイル時間 | 791 ms |
| コンパイル使用メモリ | 92,652 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-06 08:41:24 |
| 合計ジャッジ時間 | 3,774 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / 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 co1[200020], co2[200020];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int h, w;
cin >> h >> w;
co1[h]++, co2[w]++;
}
int co = 0, ans = 0;
for (int i = 1; i <= 200000; i++) {
co += abs(co1[i] - co2[i]);
if (co1[i] != 0) {
ans++;
}
}
if (co == 0) {
cout << ans << endl;
}
else if (co == 2) {
cout << 1 << endl;
}
else {
cout << 0 << endl;
}
}