結果

問題 No.1415 100の倍数かつ正整数(1)
ユーザー Saleh IsayevSaleh Isayev
提出日時 2021-03-05 23:09:07
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,476 bytes
コンパイル時間 2,772 ms
コンパイル使用メモリ 166,656 KB
実行使用メモリ 817,976 KB
最終ジャッジ日時 2024-04-16 11:08:00
合計ジャッジ時間 8,877 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long ll;
#define int ll
#define endl '\n'
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define pii pair<int , int>
#define F first
#define S second
#define M_PI 3.14159265358979323846
const int mod = 1000000007;
const int MAXX = 1e6 + 5;

int t , n , m , x , y , a , b , c , dn;

signed main()
{
    _FastIO;
    scanf("%lld" , &t);
    while(t--){
        scanf("%lld %lld %lld %lld" , &n , &m , &x , &y);
        map<int , int> d;
        map<int , vector<int> > adj;
        while(m--){
            scanf("%lld %lld %lld %lld" , &a , &b , &c , &dn);
            adj[a].push_back(c);
            adj[a].push_back(dn);
            adj[b].push_back(c);
            adj[b].push_back(dn);
        }
        if(x == y){
            putchar('0');
            putchar('\n');
            continue;
        }
        queue<int> q;
        q.push(x);
        while(!q.empty()){
            int from = q.front();
            q.pop();
            for(int i = 0; i < adj[from].size(); i++){
                int to = adj[from][i];
                if(!d[to]){
                    d[to] = d[from] + 1;
                    q.push(to);
                }
            }
        }
        if(!d[y]){
            printf("-1");
            putchar('\n');
            continue;
        }
        printf("%lld" , d[y]);
        putchar('\n');
    }
    return 0;
}
0