Submission #71498664


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a),E##i=(b);i<=E##i;i++)
#define REV(i,a,b) for(int i=(a),E##i=(b);i>=E##i;i--)
#define CLOSE_TIE ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define psbk push_back
#define endl '\n'
template <typename T>
void _outval(string s,int p,const T &t) {cout<<s.substr(p,s.length()-p)<<'='<<t<<endl; }
template <typename T, typename... Args>
void _outval(string s,int p,const T &t,const Args &...rest){
    string n="";
    while(s[p]!=',') n+=s[p++];
    cout<<n<<'='<<t<<", ";
    _outval(s,p+1,rest...);
}
#define outval(...) _outval(#__VA_ARGS__,0,__VA_ARGS__)
#define outarr(a,be,ed)\
{cout<<(#a)<<": ";\
FOR(iiii,be,ed)cout<<'['<<iiii<<"]="<<a[iiii]<<(iiii<ed?", ":"\n");}
const int N=3e5+5;
int n,m,Q;
bool bk[N];
vector<int> e[N];
signed main(){
    CLOSE_TIE
    cin>>n>>m;
    FOR(i,1,m){
        int u,v; cin>>u>>v;
        e[v].psbk(u);
    }
    cin>>Q;
    queue<int> q;
    while(Q--){
        int op,u;
        cin>>op>>u;
        if(op==1){
            if(bk[u]) continue; bk[u]=1;
            q.push(u);
            while(!q.empty()){
                int u=q.front(); q.pop();
                for(int v:e[u])
                    if(!bk[v]){
                        bk[v]=1;
                        q.push(v);
                    }
            }
        }else cout<<(bk[u]?"Yes\n":"No\n");
    }
    return 0;
}

Submission Info

Submission Time
Task D - Reachability Query 2
User FYCCCTA2011
Language C++23 (GCC 15.2.0)
Score 425
Code Size 1473 Byte
Status AC
Exec Time 140 ms
Memory 20404 KiB

Compile Error

./Main.cpp: In function 'int main()':
./Main.cpp:39:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   39 |             if(bk[u]) continue; bk[u]=1;
      |             ^~
./Main.cpp:39:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   39 |             if(bk[u]) continue; bk[u]=1;
      |                                 ^~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 1
AC × 30
Set Name Test Cases
Sample sample_01.txt
All min.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, sample_01.txt
Case Name Status Exec Time Memory
min.txt AC 2 ms 3376 KiB
random_01.txt AC 83 ms 16708 KiB
random_02.txt AC 82 ms 16896 KiB
random_03.txt AC 45 ms 7232 KiB
random_04.txt AC 58 ms 8292 KiB
random_05.txt AC 23 ms 3840 KiB
random_06.txt AC 20 ms 3508 KiB
random_07.txt AC 29 ms 4912 KiB
random_08.txt AC 80 ms 14528 KiB
random_09.txt AC 28 ms 4204 KiB
random_10.txt AC 30 ms 4276 KiB
random_11.txt AC 53 ms 7244 KiB
random_12.txt AC 89 ms 15676 KiB
random_13.txt AC 27 ms 4520 KiB
random_14.txt AC 24 ms 4188 KiB
random_15.txt AC 50 ms 9148 KiB
random_16.txt AC 58 ms 9280 KiB
random_17.txt AC 44 ms 6200 KiB
random_18.txt AC 76 ms 20256 KiB
random_19.txt AC 20 ms 3520 KiB
random_20.txt AC 26 ms 4104 KiB
random_21.txt AC 79 ms 16124 KiB
random_22.txt AC 85 ms 20404 KiB
random_23.txt AC 48 ms 9104 KiB
random_24.txt AC 78 ms 20324 KiB
random_25.txt AC 140 ms 20216 KiB
random_26.txt AC 133 ms 20352 KiB
random_27.txt AC 102 ms 20356 KiB
random_28.txt AC 44 ms 6108 KiB
sample_01.txt AC 2 ms 3532 KiB