結果
| 問題 | 
                            No.92 逃走経路
                             | 
                    
| コンテスト | |
| ユーザー | 
                             goodbaton
                         | 
                    
| 提出日時 | 2015-08-11 01:12:35 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 4 ms / 5,000 ms | 
| コード長 | 1,215 bytes | 
| コンパイル時間 | 624 ms | 
| コンパイル使用メモリ | 72,580 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-18 06:36:31 | 
| 合計ジャッジ時間 | 1,292 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 18 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |     scanf("%d%d%d",&n,&m,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:31:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |         scanf("%d%d%d",&a[i],&b[i],&c[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:39:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |         scanf("%d",&d);
      |         ~~~~~^~~~~~~~~
            
            ソースコード
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>
typedef long long ll;
using namespace std;
#define mod 1000000007
#define INF 1000000000
#define LLINF 2000000000000000000LL
#define PI 3.1415926536
#define SIZE 1000
int main(){
    int n,m,k,a[SIZE],b[SIZE],c[SIZE],d,ans=0;
    bool dp[1010][101]={0};
    
    scanf("%d%d%d",&n,&m,&k);
    
    for(int i=0;i<m;i++){
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
    }
    
    for(int i=1;i<=n;i++){
        dp[0][i]=true;
    }
    
    for(int i=0;i<k;i++){
        scanf("%d",&d);
        
        for(int j=0;j<m;j++){
            if(c[j]==d){
                
                if(dp[i][a[j]])
                    dp[i+1][b[j]]=true;
                
                if(dp[i][b[j]])
                    dp[i+1][a[j]]=true;
                
            }
        }
    }
    
    for(int i=1;i<=n;i++)
        if(dp[k][i]) ans++;
    
    printf("%d\n",ans);
    
    for(int i=1;i<=n;i++){
        if(dp[k][i]){
            printf(i<n?"%d ":"%d\n",i);
        }
    }
    
    
    return 0;
}
            
            
            
        
            
goodbaton