結果

問題 No.408 五輪ピック
ユーザー dnkdnk
提出日時 2016-08-05 23:25:50
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,275 bytes
コンパイル時間 1,580 ms
コンパイル使用メモリ 156,756 KB
最終ジャッジ日時 2024-04-24 18:19:25
合計ジャッジ時間 3,083 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp:6:19: error: ‘std::vector<int> nice [50000]’ redeclared as different kind of entity
    6 | vector<int> nice[N];
      |                   ^
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/11/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:43,
                 from main.cpp:1:
/usr/include/unistd.h:619:12: note: previous declaration ‘int nice(int)’
  619 | extern int nice (int __inc) __THROW __wur;
      |            ^~~~
main.cpp: In function ‘int main()’:
main.cpp:30:40: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |         if (depth[a[i]] == 1) nice[b[i]].push_back(a[i]);
      |                                        ^
main.cpp:30:42: error: request for member ‘push_back’ in ‘*(nice + ((sizetype)b[i]))’, which is of non-class type ‘int(int) noexcept’ {aka ‘int(int)’}
   30 |         if (depth[a[i]] == 1) nice[b[i]].push_back(a[i]);
      |                                          ^~~~~~~~~
main.cpp:31:40: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   31 |         if (depth[b[i]] == 1) nice[a[i]].push_back(b[i]);
      |                                        ^
main.cpp:31:42: error: request for member ‘push_back’ in ‘*(nice + ((sizetype)a[i]))’, which is of non-class type ‘int(int) noexcept’ {aka ‘int(int)’}
   31 |         if (depth[b[i]] == 1) nice[a[i]].push_back(b[i]);
      |                                          ^~~~~~~~~
main.cpp:34:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   34 |         if (nice[a[i]].size() > 2 && nice[b[i]].size() > 2) {
      |                      ^
main.cpp:34:24: error: request for member ‘size’ in ‘*(nice + ((sizetype)a[i]))’, which is of non-class type ‘int(int) noexcept’ {aka ‘int(int)’}
   34 |         if (nice[a[i]].size() >

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const int N = (int) 5e4;
vector<int> graph[N];
vector<int> nice[N];
bool visited[N];
int depth[N], a[N], b[N];

int main() {
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int m; cin >> m;
    for (int i = 0; i < m; ++i) {
        int u, v; cin >> u >> v; --u; --v;
        graph[u].push_back(v);
        graph[v].push_back(u);
        a[i] = u; b[i] = v;
    }
    queue<int> q; visited[0] = true; q.push(0);
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (auto v : graph[u]) if (!visited[v]) {
            visited[v] = true;
            depth[v] = depth[u] + 1;
            q.push(v);
        }
    }
    for (int i = 0; i < m; ++i) {
        if (depth[a[i]] == 1) nice[b[i]].push_back(a[i]);
        if (depth[b[i]] == 1) nice[a[i]].push_back(b[i]);
    }
    for (int i = 0; i < m; ++i) if (a[i] != 0 && b[i] != 0) {
        if (nice[a[i]].size() > 2 && nice[b[i]].size() > 2) {
            cout << "YES" << endl;
            return 0;
        }
        for (auto x : nice[a[i]]) if (x != b[i])
            for (auto y : nice[b[i]]) if (y != a[i] && x != y) {
                cout << "YES" << endl;
                return 0;
            }
    }
    cout << "NO" << endl;
    return 0;
}
0