結果
| 問題 |
No.92 逃走経路
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2015-03-03 21:16:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,319 bytes |
| コンパイル時間 | 373 ms |
| コンパイル使用メモリ | 46,848 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-24 01:16:50 |
| 合計ジャッジ時間 | 3,575 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 2 RE * 16 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:59:14: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
59 | printf("%d\n", cs.size());
| ~^ ~~~~~~~~~
| | |
| int std::vector<int>::size_type {aka long unsigned int}
| %ld
main.cpp:13:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d %d %d", &N, &M, &K);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:17:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
17 | scanf("%d %d %d", &a, &b, &c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:23:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
23 | scanf("%d", d+i);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <cstdio>
#include <vector>
#include <tuple>
typedef std::tuple<int,int,int> T;
int N, M, K;
std::vector<T> es;
int d[1000];
bool used[2][101];
int main(){
scanf("%d %d %d", &N, &M, &K);
for(int i=0;i<M;i++){
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
es.push_back(std::make_tuple(a, b, c));
}
for(int i=0;i<K;i++){
scanf("%d", d+i);
}
for(const T& t : es){
if(std::get<2>(t) == d[0]){
used[0][std::get<0>(t)] = true;
used[0][std::get<1>(t)] = true;
}
}
int prev = 0, next = 1;
for(int i=1;i<K;i++){
for(int j=1;j<=N;j++){used[next][j] = false;}
for(const T& t : es){
if(std::get<2>(t) == d[i]){
if(used[prev][std::get<0>(t)]){
used[next][std::get<1>(t)] = true;
}
if(used[prev][std::get<1>(t)]){
used[next][std::get<0>(t)] = true;
}
}
}
prev = !prev;
next = !next;
}
std::vector<int> cs;
for(int i=1;i<=N;i++){
if(used[K-1][i]){
cs.push_back(i);
}
}
printf("%d\n", cs.size());
for(int i=0;i<cs.size();i++){
printf("%d%c", cs[i], " \n"[i+1==cs.size()]);
}
}
tottoripaper