C++2.1 KB
#include "bits/stdc++.h"
using namespace std;
const int N = 1104;
int mtx[N][N], vis[N], dis[N], low[N];
int parent[N];
vector< int > g[N];
void dfs( int u, int par, int dep )
{
//cout<<u<<endl;
vis[u] = 1;
dis[u] = low[u] = dep;
for(auto v : g[u]) {
if( vis[v] && v != par )
low[u] = min(low[u], dis[v]);
if(!vis[v]) {
dfs(v, u, dep + 1);
low[u] = min( low[u], low[v] );
if( low[v] > dis[u] ) {
mtx[u][v] = 1;
mtx[v][u] = 1;
}
}
}
}
int main()
{
int n, m, qq;
scanf("%d %d %d", &n, &m, &qq);
for(int i = 0; i < m; i++) {
int x, y; scanf("%d %d", &x, &y);
g[x].push_back(y), g[y].push_back(x);
}
dfs(1, 0, 0);
while(qq--) {
int from, to;
scanf("%d %d", &from, &to);
memset(vis, 0, sizeof vis);
queue< int> q;
q.push(from);
vis[from] = 1;
parent[from] = from;
while(!q.empty()) {
int top = q.front(); q.pop();
for(auto v : g[top]) {
if(vis[v]) continue;
vis[v]=1;
parent[v] = top;
q.push(v);
}
}
int pos = to;
int ans = 1;
while( parent[pos] != pos ) {
if( mtx[ parent[pos] ][pos] == 0 ) {
ans = 0;
break;
}
pos = parent[pos];
}
printf("%d\n", ans);
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Summary

User: Ashini Singha

Verdict: 100 points

Language: C++

CPU Time usage: 32 ms

Memory usage: 4572 KB

Source code: 2.1 KB

Compilation
Compilation done in 2.112 seconds.
Results
Test Number
CPU Usage
Memory Usage
Result
2124 ms4476 KBOK
2021 ms4344 KBOK
1921 ms4356 KBOK
1821 ms4232 KBOK
1716 ms632 KBOK
1620 ms2428 KBOK
1524 ms3572 KBOK
1427 ms4572 KBOK
1322 ms4068 KBOK
1232 ms4240 KBOK
1120 ms3820 KBOK
1023 ms3948 KBOK
923 ms3728 KBOK
822 ms2756 KBOK
713 ms2180 KBOK
612 ms1560 KBOK
55 ms908 KBOK
47 ms844 KBOK
37 ms760 KBOK
26 ms672 KBOK
16 ms668 KBOK
08 ms644 KBOK