# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
698993 | 2023-02-15T07:48:00 Z | jamezzz | Inside information (BOI21_servers) | C++17 | 1974 ms | 2368 KB |
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG #define dbg(...) printf(__VA_ARGS__); #define getchar_unlocked getchar #else #define dbg(...) #endif #define sf scanf #define pf printf #define fi first #define se second #define pb push_back #define psf push_front #define ppb pop_back #define ppf pop_front #define sz(x) (int)x.size() #define mnto(x,y) x=min(x,(__typeof__(x))y) #define mxto(x,y) x=max(x,(__typeof__(x))y) #define INF 1023456789 #define LINF 1023456789123456789 #define all(x) x.begin(),x.end() #define lb(x,v) (lower_bound(all(x),v)-x.begin()) #define ub(x,v) (upper_bound(all(x),v)-x.begin()) #define disc(x) sort(all(x));x.resize(unique(all(x))-x.begin()); typedef long long ll; typedef long double ld; typedef pair<int,int> ii; typedef pair<ll,ll> pll; typedef tuple<int,int,int> iii; typedef tuple<int,int,int,int> iiii; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<ii> vii; mt19937 rng(time(0)); #define mod 1000000007 inline int add(int a,int b){ int r=a+b; while(r>=mod)r-=mod; while(r<0)r+=mod; return r; } inline int mult(int a,int b){ return (int)(((ll)(a*b))%mod); } inline int rd(){ int x=0; char ch=getchar_unlocked(); while(!(ch&16))ch=getchar();//keep reading while current character is whitespace while(ch&16){//this will break when ‘\n’ or ‘ ‘ is encountered x=(x<<3)+(x<<1)+(ch&15); ch=getchar_unlocked(); } return x; } #define maxn 4005 int n,k,wt[maxn]; vii AL[maxn]; int main(){ sf("%d%d",&n,&k); for(int i=0;i<n-1+k;++i){ char c;sf(" %c",&c); if(c=='S'){ int a,b;sf("%d%d",&a,&b); AL[a].pb({b,i}); AL[b].pb({a,i}); } else if(c=='Q'){ int a,b;sf("%d%d",&a,&b); memset(wt,-1,sizeof wt); queue<int> q; wt[b]=0; q.push(b); while(!q.empty()){ int u=q.front();q.pop(); for(auto[v,w]:AL[u]){ if(wt[v]!=-1||wt[u]>w)continue; wt[v]=w;q.push(v); } } if(wt[a]!=-1)pf("yes\n"); else pf("no\n"); } else{ int b;sf("%d",&b); memset(wt,-1,sizeof wt); queue<int> q; wt[b]=0; q.push(b); while(!q.empty()){ int u=q.front();q.pop(); for(auto[v,w]:AL[u]){ if(wt[v]!=-1||wt[u]>w)continue; wt[v]=w;q.push(v); } } int ans=0; for(int i=1;i<=n;++i)if(wt[i]!=-1)++ans; pf("%d\n",ans); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 81 ms | 984 KB | Output is correct |
2 | Correct | 107 ms | 1100 KB | Output is correct |
3 | Correct | 211 ms | 2280 KB | Output is correct |
4 | Correct | 88 ms | 2252 KB | Output is correct |
5 | Correct | 92 ms | 2252 KB | Output is correct |
6 | Correct | 1727 ms | 2368 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 81 ms | 984 KB | Output is correct |
2 | Correct | 107 ms | 1100 KB | Output is correct |
3 | Correct | 211 ms | 2280 KB | Output is correct |
4 | Correct | 88 ms | 2252 KB | Output is correct |
5 | Correct | 92 ms | 2252 KB | Output is correct |
6 | Correct | 1727 ms | 2368 KB | Output is correct |
7 | Correct | 92 ms | 1576 KB | Output is correct |
8 | Correct | 270 ms | 1904 KB | Output is correct |
9 | Correct | 458 ms | 2188 KB | Output is correct |
10 | Correct | 292 ms | 1984 KB | Output is correct |
11 | Correct | 284 ms | 1812 KB | Output is correct |
12 | Correct | 1974 ms | 2168 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 107 ms | 972 KB | Output is correct |
2 | Runtime error | 1 ms | 596 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 107 ms | 972 KB | Output is correct |
2 | Runtime error | 1 ms | 596 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 81 ms | 1012 KB | Output is correct |
2 | Runtime error | 1 ms | 596 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 81 ms | 1012 KB | Output is correct |
2 | Runtime error | 1 ms | 596 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 102 ms | 1016 KB | Output is correct |
2 | Runtime error | 1 ms | 596 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 102 ms | 1016 KB | Output is correct |
2 | Runtime error | 1 ms | 596 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 84 ms | 968 KB | Output is correct |
2 | Runtime error | 1 ms | 596 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 84 ms | 968 KB | Output is correct |
2 | Runtime error | 1 ms | 596 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 80 ms | 972 KB | Output is correct |
2 | Correct | 105 ms | 1160 KB | Output is correct |
3 | Correct | 194 ms | 2292 KB | Output is correct |
4 | Correct | 99 ms | 2280 KB | Output is correct |
5 | Correct | 88 ms | 2200 KB | Output is correct |
6 | Correct | 1842 ms | 2368 KB | Output is correct |
7 | Correct | 93 ms | 1644 KB | Output is correct |
8 | Runtime error | 1 ms | 596 KB | Execution killed with signal 11 |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 80 ms | 972 KB | Output is correct |
2 | Correct | 105 ms | 1160 KB | Output is correct |
3 | Correct | 194 ms | 2292 KB | Output is correct |
4 | Correct | 99 ms | 2280 KB | Output is correct |
5 | Correct | 88 ms | 2200 KB | Output is correct |
6 | Correct | 1842 ms | 2368 KB | Output is correct |
7 | Correct | 93 ms | 1644 KB | Output is correct |
8 | Runtime error | 1 ms | 596 KB | Execution killed with signal 11 |
9 | Halted | 0 ms | 0 KB | - |