結果
問題 | No.239 にゃんぱすー |
ユーザー |
![]() |
提出日時 | 2018-02-27 23:36:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 1,115 bytes |
コンパイル時間 | 886 ms |
コンパイル使用メモリ | 77,056 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-14 04:30:40 |
合計ジャッジ時間 | 2,243 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
// No.239 にゃんぱすー// https://yukicoder.me/problems/no/239//#include <iostream>#include <vector>#include <string>using namespace std;int solve(vector<vector<string>>& greetings, int N);int main() {int N;cin >> N;vector<vector<string>> greetings;greetings.resize(N);for (auto y = 0; y < N; y++) {greetings[y].resize(N);for (auto x = 0; x < N; x++) {cin >> greetings[y][x];}}int ans = solve(greetings, N);cout << ans << endl;}int solve(vector<vector<string>>& greetings, int N) {vector<int> candidates;for (auto y = 0; y < N; y++) {for (auto x = 0; x < N; x++) {if (greetings[y][x] == "nyanpass")greetings[x][y] = "nyanpass";}}for (auto y = 0; y < N; y++) {int c = 0;for (auto j: greetings[y]) {if (j == "nyanpass")c++;}if (c == (N - 1))candidates.push_back(y+1);}if (candidates.size() == 1)return candidates[0];elsereturn -1;}