結果

問題 No.239 にゃんぱすー
ユーザー YoureinYourein
提出日時 2021-11-14 21:14:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 2,691 bytes
コンパイル時間 892 ms
コンパイル使用メモリ 103,540 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-20 05:40:12
合計ジャッジ時間 2,937 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 7 ms
4,380 KB
testcase_13 AC 7 ms
4,380 KB
testcase_14 AC 10 ms
4,376 KB
testcase_15 AC 12 ms
4,376 KB
testcase_16 AC 14 ms
4,380 KB
testcase_17 AC 18 ms
4,380 KB
testcase_18 AC 20 ms
4,380 KB
testcase_19 AC 24 ms
4,380 KB
testcase_20 AC 25 ms
4,376 KB
testcase_21 AC 31 ms
4,376 KB
testcase_22 AC 34 ms
4,376 KB
testcase_23 AC 38 ms
4,376 KB
testcase_24 AC 43 ms
4,376 KB
testcase_25 AC 49 ms
4,376 KB
testcase_26 AC 54 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 4 ms
4,376 KB
testcase_29 AC 6 ms
4,380 KB
testcase_30 AC 10 ms
4,380 KB
testcase_31 AC 15 ms
4,376 KB
testcase_32 AC 21 ms
4,380 KB
testcase_33 AC 27 ms
4,380 KB
testcase_34 AC 36 ms
4,380 KB
testcase_35 AC 43 ms
4,380 KB
testcase_36 AC 54 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
using namespace std;
using ll = long long;

namespace cpio{
    //IO library for Competitive-Programming
    struct scanner {
        private:
            struct reader {
                template <typename T> operator T() const {T buf; std::cin >> buf; return buf;}
            };
        public:
            scanner() {std::cin.sync_with_stdio(false); std::cin.tie(nullptr);}

            reader operator()() const {return reader();}
    };

    void yes(){
        cout << "Yes\n";
    }

    void no(){
        cout << "No\n";
    }
}

namespace cpmath{
    //Math library for Competitive-Programming
    ll factorial(ll a, ll b = -1, const ll fmod = -1){
        ll ans = 1;
        if (fmod > 1) {
            if (b == -1) for (ll i = a; i > 1; i--) ans = ((ans%fmod)*(i%fmod))%fmod;
            else for (ll i = a; i >= b; i--) ans = ((ans%fmod)*(i%fmod))%fmod;
        }
        else{
            if (b == -1) for (ll i = a; i > 1; i--) ans = ans*i;
            else for(ll i = a; i >= b; i--) ans = ans*i;
        }
        return ans;
    }

    ll fastpow(ll m, ll p){
        if (p == 0) return 1;
        if (p%2 == 0){
            ll t = fastpow(m, p/2);
            return t*t;
        }
        return m*fastpow(m, p-1);
    }

    ll modpow(ll m, ll p, const ll fmod){
        if (p == 0) return 1;
        if (p%2 == 0){
            ll t = modpow(m, p/2, fmod);
            return (t*t)%fmod;
        }
        return (m*modpow(m, p-1, fmod))%fmod;
    }

    const ll mod97 = 1000000007;
    const ll mod99 = 1000000009;
    const ll mod89 = 998244353;
}

cpio::scanner in; //Declaration of inputclass
using cpio::yes;
using cpio::no;
using cpmath::mod89;
using cpmath::mod97;
using cpmath::mod99;

int main(){
    int n = in();
    string greeting[n][n];

    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            cin >> greeting[i][j];
        }
    }

    vector<bool> nyanpass(n, true);

    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            if (greeting[i][j] != "nyanpass" && i != j){
                cerr << i << " " << j << endl;
                nyanpass[j] = false;
            }
        }
    }

    for (auto x : nyanpass){
        cerr << x << " ";
    }
    cerr << endl;

    int ans = 0;

    for (int i = 0; i < n; i++){
        if (nyanpass[i] == true){
            if (ans == 0) ans = i+1;
            else {cout << -1 << endl; return 0;}
        }
    }
    
    if (ans == 0) cout << -1 << endl;
    else cout << ans << endl;
}
0