結果

問題 No.408 五輪ピック
ユーザー treeone
提出日時 2016-08-12 19:19:04
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 25 ms / 5,000 ms
コード長 1,169 bytes
コンパイル時間 1,678 ms
コンパイル使用メモリ 161,800 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2024-11-07 12:12:03
合計ジャッジ時間 3,130 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:17: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=]
   16 |         scanf("%d %d", &a[i], &b[i]);
      |                ~^      ~~~~~
      |                 |      |
      |                 int*   long long int*
      |                %lld
main.cpp:16:20: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘long long int*’ [-Wformat=]
   16 |         scanf("%d %d", &a[i], &b[i]);
      |                   ~^          ~~~~~
      |                    |          |
      |                    int*       long long int*
      |                   %lld
main.cpp:16:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |         scanf("%d %d", &a[i], &b[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
//#define FOR(i, a) for(auto& i : a)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

int n, m;
int a[50010], b[50010];
vector<int> e[20010], p[20010];

signed main(){
    cin >> n >> m;
    rep(i, 0, m){
        scanf("%d %d", &a[i], &b[i]);
        a[i]--;
        b[i]--;
        e[a[i]]. push_back(b[i]);
        e[b[i]]. push_back(a[i]);
    }
    //FOR(i, e[0]) FOR(j, e[i])
    rep(i, 0, e[0].size()){
        int t = e[0][i];
        rep(j, 0, e[t].size()){
            p[e[t][j]]. push_back(t);
        }
    }

    rep(i, 0, m){
        if(a[i] == 0 || b[i] == 0) continue;
        if(p[a[i]].size() > 3 && p[b[i]].size() > 3){
            cout << "YES" << endl;
            return 0;
        }
        rep(j, 0, p[a[i]].size()){
            rep(k, 0, p[b[i]].size()){
                if(p[a[i]][j] != p[b[i]][k] && p[a[i]][j] != b[i] && p[b[i]][k] != a[i]){
                    cout << "YES" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "NO" << endl;
}
0