#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
//#include "job.h"
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mmax=1e3+50;
const int mod=1e9+7;
using namespace std;
int x,y,z,nr,vz[mmax],q,i,t,n,m;
vector<pair<pair<int,int>,int> >e;
vector<int>a[nmax];
void dfs(int x,int z)
{
vz[x]=1;
nr++;
for(int i=0;i<a[x].size();i++)
{
int y=a[x][i],u=x^e[y].fr.fr^e[y].fr.sc;
if(vz[u] || e[y].sc<z)continue;
dfs(u,z);
}
}
int main()
{
//freopen("sol.in","r",stdin);
//freopen("sol.out","w",stdout);
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
cin>>n>>m;
for(i=1;i<=m;i++)
{
cin>>x>>y>>z;
a[x].pb(i-1);
a[y].pb(i-1);
e.pb(mkp(mkp(x,y),z));
}
cin>>q;
while(q--)
{
cin>>t>>x>>z;
if(t==1)
{
x--;
e[x].sc=z;
}
else
{
memset(vz,0,sizeof(vz));
nr=0;
dfs(x,z);
cout<<nr<<'\n';
}
}
return 0;
}
Compilation message
bridges.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization("O3")
bridges.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization("unroll-loops")
bridges.cpp: In function 'void dfs(int, int)':
bridges.cpp:30:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<a[x].size();i++)
~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
2680 KB |
Output is correct |
2 |
Correct |
5 ms |
2680 KB |
Output is correct |
3 |
Correct |
58 ms |
3064 KB |
Output is correct |
4 |
Correct |
9 ms |
2808 KB |
Output is correct |
5 |
Correct |
13 ms |
2924 KB |
Output is correct |
6 |
Correct |
12 ms |
2808 KB |
Output is correct |
7 |
Correct |
11 ms |
2808 KB |
Output is correct |
8 |
Correct |
12 ms |
2808 KB |
Output is correct |
9 |
Correct |
13 ms |
2808 KB |
Output is correct |
10 |
Correct |
10 ms |
2808 KB |
Output is correct |
11 |
Correct |
9 ms |
2808 KB |
Output is correct |
12 |
Correct |
9 ms |
2808 KB |
Output is correct |
13 |
Correct |
13 ms |
2808 KB |
Output is correct |
14 |
Correct |
11 ms |
2808 KB |
Output is correct |
15 |
Correct |
13 ms |
2904 KB |
Output is correct |
16 |
Correct |
11 ms |
2808 KB |
Output is correct |
17 |
Correct |
11 ms |
2844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
35 ms |
10924 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
26 ms |
8976 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
79 ms |
14236 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
35 ms |
10924 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
2680 KB |
Output is correct |
2 |
Correct |
5 ms |
2680 KB |
Output is correct |
3 |
Correct |
58 ms |
3064 KB |
Output is correct |
4 |
Correct |
9 ms |
2808 KB |
Output is correct |
5 |
Correct |
13 ms |
2924 KB |
Output is correct |
6 |
Correct |
12 ms |
2808 KB |
Output is correct |
7 |
Correct |
11 ms |
2808 KB |
Output is correct |
8 |
Correct |
12 ms |
2808 KB |
Output is correct |
9 |
Correct |
13 ms |
2808 KB |
Output is correct |
10 |
Correct |
10 ms |
2808 KB |
Output is correct |
11 |
Correct |
9 ms |
2808 KB |
Output is correct |
12 |
Correct |
9 ms |
2808 KB |
Output is correct |
13 |
Correct |
13 ms |
2808 KB |
Output is correct |
14 |
Correct |
11 ms |
2808 KB |
Output is correct |
15 |
Correct |
13 ms |
2904 KB |
Output is correct |
16 |
Correct |
11 ms |
2808 KB |
Output is correct |
17 |
Correct |
11 ms |
2844 KB |
Output is correct |
18 |
Runtime error |
35 ms |
10924 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Halted |
0 ms |
0 KB |
- |