結果

問題 No.408 五輪ピック
ユーザー moyashi_senpaimoyashi_senpai
提出日時 2016-08-06 01:07:01
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,447 bytes
コンパイル時間 812 ms
コンパイル使用メモリ 95,728 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 16:11:17
合計ジャッジ時間 2,089 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 11 ms
5,376 KB
testcase_06 AC 8 ms
5,376 KB
testcase_07 AC 11 ms
5,376 KB
testcase_08 AC 9 ms
5,376 KB
testcase_09 AC 9 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 8 ms
5,376 KB
testcase_12 AC 12 ms
5,376 KB
testcase_13 AC 10 ms
5,376 KB
testcase_14 WA -
testcase_15 AC 10 ms
5,376 KB
testcase_16 AC 11 ms
5,376 KB
testcase_17 AC 12 ms
5,376 KB
testcase_18 AC 12 ms
5,376 KB
testcase_19 AC 14 ms
5,376 KB
testcase_20 AC 5 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 7 ms
5,376 KB
testcase_23 AC 16 ms
5,376 KB
testcase_24 WA -
testcase_25 AC 10 ms
5,376 KB
testcase_26 AC 15 ms
5,376 KB
testcase_27 AC 17 ms
5,376 KB
testcase_28 AC 87 ms
5,376 KB
testcase_29 AC 82 ms
5,376 KB
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |         scanf("%d %d", &n, &m);
      |         ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:31:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |                 scanf("%d %d", &a, &b);
      |                 ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>

using namespace std;

#define Getsign(n) ((n > 0) - (n < 0))
#define QWERTYR(c) (c == 'y' || c == 'u' || (c >= 'h' && c <= 'p') ?	true : false)
map<string, int> roma_time = { { "I",1 },{ "II",2 },{ "III",3 },{ "IIII",4 },{ "V",5 },{ "VI",6 },{ "VII",7 },{ "VIII",8 },{ "IX",9 },{ "X",10 },{ "XI",11 },{ "XII",12 } };

typedef vector<int> Ivec;
typedef pair<int, int> pii;

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	vector<vector<int>> graph(n, vector<int>());
	for (int i = 0; m > i; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	queue<int> que;
	array<bool, 20000> tesu;
	for (int i = 0; n > i; i++) {
		tesu[i] = false;
	}
	for (int i = 0; graph[0].size() > i; i++) {
		que.push(graph[0][i]);
	}
	while (!que.empty()) {
		int vertex = que.front();
		que.pop();
		
		if (tesu[vertex]) {
			for (int i = 0; graph[vertex].size() > i; i++) {
				int tar = graph[vertex][i];
				if (tesu[tar]) {
					printf("YES\n");
					return 0;
				}
			}
		}
		else {
			for (int i = 0; graph[vertex].size() > i; i++) {
				tesu[graph[vertex][i]] = true;
				que.push(graph[vertex][i]);
			}
		}
	}

	printf("NO\n");
	return 0;
}
0