結果

問題 No.1605 Matrix Shape
ユーザー chocoruskchocorusk
提出日時 2021-08-09 10:02:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,200 bytes
コンパイル時間 3,062 ms
コンパイル使用メモリ 188,880 KB
実行使用メモリ 5,300 KB
最終ジャッジ日時 2023-10-21 07:51:12
合計ジャッジ時間 6,777 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,296 KB
testcase_01 AC 3 ms
5,296 KB
testcase_02 AC 3 ms
5,296 KB
testcase_03 AC 3 ms
5,296 KB
testcase_04 WA -
testcase_05 AC 3 ms
5,296 KB
testcase_06 AC 3 ms
5,296 KB
testcase_07 AC 3 ms
5,296 KB
testcase_08 AC 3 ms
5,296 KB
testcase_09 AC 3 ms
5,296 KB
testcase_10 AC 3 ms
5,296 KB
testcase_11 AC 3 ms
5,296 KB
testcase_12 AC 3 ms
5,296 KB
testcase_13 AC 3 ms
5,296 KB
testcase_14 AC 3 ms
5,296 KB
testcase_15 AC 3 ms
5,296 KB
testcase_16 AC 3 ms
5,296 KB
testcase_17 AC 3 ms
5,296 KB
testcase_18 AC 3 ms
5,296 KB
testcase_19 AC 123 ms
5,296 KB
testcase_20 AC 104 ms
5,296 KB
testcase_21 AC 103 ms
5,296 KB
testcase_22 WA -
testcase_23 AC 118 ms
5,296 KB
testcase_24 AC 107 ms
5,296 KB
testcase_25 AC 73 ms
5,296 KB
testcase_26 AC 75 ms
5,296 KB
testcase_27 AC 74 ms
5,296 KB
testcase_28 WA -
testcase_29 AC 73 ms
5,296 KB
testcase_30 AC 101 ms
5,296 KB
testcase_31 AC 101 ms
5,296 KB
testcase_32 AC 98 ms
5,296 KB
testcase_33 WA -
testcase_34 AC 100 ms
5,296 KB
testcase_35 AC 87 ms
5,296 KB
testcase_36 AC 52 ms
5,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n;
    cin>>n;
    int d1[200020]={}, d2[200020]={};
    for(int i=0; i<n; i++){
        int h, w; cin>>h>>w;
        d1[h]++; d2[w]++;
    }
    int c0=0, c1=0, c2=0;
    for(int i=1; i<=200000; i++){
        if(d1[i]==0 && d2[i]==0) continue;
        int d=d1[i]-d2[i];
        if(d==0) c0++;
        else if(d==1) c1++;
        else if(d==-1) c2++;
        else{
            cout<<0<<endl;
            return 0;
        }
    }
    if(c1 || c2){
        if(c1==1 && c2==1) cout<<1<<endl;
        else cout<<0<<endl;
        return 0;
    }
    cout<<c0<<endl;
    return 0;
}
0