結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー ngtkana
提出日時 2020-04-20 19:29:39
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,446 bytes
コンパイル時間 2,498 ms
コンパイル使用メモリ 202,980 KB
最終ジャッジ日時 2025-01-09 21:57:42
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1 RE * 1
other WA * 1 RE * 45
権限があれば一括ダウンロードができます

ソースコード

diff #

/* validator */

#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
int main(){
    auto read=[]{
        std::string s;std::getline(std::cin,s);
        lint n=s.length();
        lint l=0,r;
        for(r=l;r<n&&s.at(r)!=' ';r++);
        assert(r-l<=9);
        lint x=std::stoll(s.substr(l,r-l));
        l=r+1;
        for(r=l;r<n&&s.at(r)!=' ';r++);
        assert(r-l<=9);
        lint y=std::stoll(s.substr(l,r-l));
        return std::pair{x,y};
    };
    auto[n,m]=read();
    assert(2<=n&&n<=200'000&&n-1<=m&&m<=200'000);
    auto[s,t]=read();
    assert(1<=s&&s<=n&&1<=t&&t<=n);
    std::vector<std::pair<ld,ld>>pts(n);
    for(lint i=0;i<n;i++){
        auto[x,y]=read();
        assert(-1'000<=x&&x<=1'000&&-1'000<=y&&y<=1'000);
        pts.at(i)={x,y};
    }
    std::vector<std::vector<lint>>g(n);
    for(lint i=0;i<n-1;i++){
        auto[u,v]=read();
        assert(1<=u&&u<=n&&1<=v&&v<=n);
        u--,v--;
        g.at(u).push_back(v);
        g.at(v).push_back(u);
    }
    std::vector<lint>que,ckd(n);
    que.push_back(s);
    for(lint k=0;k<(lint)que.size();k++){
        lint x=que.at(k);
        for(lint y:g.at(x)){
            if(std::exchange(ckd.at(y),true))continue;
            que.push_back(y);
        }
    }
    assert(ckd.at(t));
    assert(!std::cin.eof());
    std::string emplyline;std::getline(std::cin,emplyline);
    assert(std::cin.eof());
}
0