QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#404081 | #4891. 树上的孤独 | Butanlishi | 0 | 1637ms | 105320kb | C++14 | 2.1kb | 2024-05-03 11:14:25 | 2024-05-03 11:14:26 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define rg int
#define ci const int
#define ls x<<1
#define rs x<<1|1
#define mid ((l+r)>>1)
#define ld long double
#define fo(i,l,r) for(int i=(l);i<=(r);++i)
#define fd(i,l,r) for(int i=(l);i>=(r);--i)
#define fu(i,l,r) for(int i=(l);i<(r);++i)
#define gcd __gcd
#define P(x) __builtin_popcountll(x)
using namespace std;
ci N=2e6+5,M=5e3+5,mod=998244353,_g=3,_ig=(mod+1)/3;
ll ksm(ll a,ll b=mod-2)
{
ll ans=1;
while(b)
{
if(b&1)ans=(ll)ans*a%mod;
a=(ll)a*a%mod,b>>=1;
}
return ans;
}
const ld eps=1e-10;
inline ll read(){ll u,f=1;char o;while((o=getchar())<48||o>57)if(o==45)f=-1;u=(o^48);while((o=getchar())>=48&&o<=57)u=(u<<1)+(u<<3)+(o^48);return u*f;}
void write(ll x){if(x<0)putchar(45),x=-x;if(x>9)write(x/10);putchar(x%10+48);}
mt19937 rad(chrono::steady_clock::now().time_since_epoch().count());
ll n,m,q,v[N],v1[N],p1,p2,d1,d2,ans;
vector<ll>w[N],w1[N];
bool f[N];
ll ceng[N];
void tree(int x,int c)
{
f[x]=1;
ceng[x]=c;
for(auto d:w[x])if(!f[d])
{
tree(d,c+1);
}
}
bool t[N];
void tr(int x,int c)
{
if(c>d1)return;
if(!t[v[x]])++ans;
t[v[x]]=1;
for(auto d:w[x])if(ceng[d]>ceng[x])
{
tr(d,c+1);
}
}
void tre(int x,int c)
{
if(c>d2)return;
if(!t[v1[x]])++ans;
t[v1[x]]=1;
for(auto d:w1[x])if(ceng[d]>ceng[x])
{
tre(d,c+1);
}
}
int main()
{//freopen("1.in","r",stdin);
// freopen("c.in","r",stdin);
// freopen("c.out","w",stdout);
int T=1;
while(T--)
{
n=read();m=read();q=read();
fu(i,1,n)
{
ll x=read(),y=read();
w[x].push_back(y);
w[y].push_back(x);
}
fu(i,1,m)
{
ll x=read(),y=read();
w1[x].push_back(y);
w1[y].push_back(x);
}
fo(i,1,n)v[i]=read();
fo(i,1,m)v1[i]=read();
tree(1,1);
ll last=0;
while(q--)
{
int op=read();
if(op==1)
{
ans=0;
fo(i,1,m)t[i]=0;
p1=read(),p2=read(),d1=(read()^last),d2=(read()^last);
tr(p1,0);
tre(p2,0);
write(last=ans),putchar('\n');
}
else
{
int x=read(),y=read();
v[x]=y;
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 8ms
memory: 97312kb
input:
20 2000 2000 8 15 8 13 14 8 14 7 12 14 12 1 9 13 9 4 5 9 5 10 2 5 2 19 6 19 6 16 11 7 11 20 18 2 18 17 3 6 1395 1783 1395 1735 1735 457 457 739 739 438 438 101 101 441 441 1879 1879 1238 1238 501 501 1732 1732 1910 1910 2000 2000 834 834 917 917 111 111 780 780 1966 1966 1604 1604 623 623 1748 1748 ...
output:
4 5 2 5 17 20 20 20 4 4 10 12 19 19 4 4 2 3 14 20 15 5 3 4 3 2 2 5 18 3 3 2 4 12 20 2 13 3 2 2 2 2 2 4 2 2 11 17 2 5 8 17 19 19 2 11 10 8 2 2 2 11 18 19 18 18 14 18 18 18 18 18 17 2 4 8 18 18 17 5 2 13 19 19 2 14 19 19 19 19 3 8 19 19 2 13 3 2 12 2 16 15 21 4 3 6 4 12 2 14 3 12 2 3 2 3 14 3 12 3 7 1...
result:
wrong answer 1st numbers differ - expected: '105', found: '4'
Subtask #2:
score: 0
Wrong Answer
Test #3:
score: 0
Wrong Answer
time: 1637ms
memory: 105320kb
input:
20 200000 500000 8 18 8 4 2 4 2 14 13 4 13 16 6 4 6 3 1 4 1 17 15 6 15 19 7 17 7 11 5 14 5 10 20 7 12 15 9 8 165302 77239 165302 198189 165302 180850 165302 192738 165302 173589 165302 194087 165302 191990 165302 167370 165302 101092 165302 92553 165302 163654 165302 122381 165302 152105 165302 1919...
output:
2 4 4 5 2 2 2 2 4 2 2 21 21 16 2 6 2 21 21 2 3 2 2 2 21 4 2 2 21 6 21 2 2 3 9 3 21 2 2 21 2 21 2 2 21 5 20 2 6 3 5 2 2 17 21 5 2 17 21 2 2 2 4 3 2 4 6 3 2 2 15 21 21 4 2 2 2 2 21 21 2 17 21 16 2 21 21 21 21 21 16 16 5 2 17 21 3 2 4 2 3 21 2 5 2 5 21 21 21 21 21 2 2 2 16 21 21 21 21 2 17 2 21 21 2 3 ...
result:
wrong answer 2nd numbers differ - expected: '17595', found: '4'
Subtask #3:
score: 0
Wrong Answer
Test #7:
score: 0
Wrong Answer
time: 151ms
memory: 101496kb
input:
20 100000 100000 16 12 16 20 6 12 6 18 2 16 2 8 5 20 5 13 3 6 3 11 19 11 19 17 9 12 9 15 4 15 4 7 10 5 14 15 14 1 85812 94626 85812 91172 91172 93788 93788 96567 96567 75524 75524 23275 23275 98340 98340 81608 81608 91480 91480 75108 75108 56605 56605 93317 93317 41617 41617 77160 77160 727 727 7559...
output:
4 8 16 21 21 21 21 21 16 5 3 3 2 18 2 3 14 21 21 19 21 21 21 21 2 2 6 2 14 7 6 17 2 18 21 7 2 17 2 2 2 2 3 2 6 4 3 2 14 21 2 14 3 16 16 3 14 21 21 21 3 2 17 8 21 2 6 17 21 21 8 21 21 21 4 2 6 2 6 8 20 21 21 2 2 14 21 21 5 2 17 21 4 3 2 2 2 14 21 21 21 2 8 8 21 7 3 2 17 21 21 8 21 2 3 17 21 3 2 6 8 4...
result:
wrong answer 1st numbers differ - expected: '2568', found: '4'
Subtask #4:
score: 0
Wrong Answer
Test #13:
score: 0
Wrong Answer
time: 1233ms
memory: 105312kb
input:
1 200000 500000 189127 137023 189127 199761 199761 160701 160701 130639 130639 190908 190908 176819 176819 193363 193363 188021 188021 182446 182446 186028 186028 198828 198828 190792 190792 155378 155378 189428 189428 177276 177276 146159 146159 175923 175923 188073 188073 182206 182206 131072 1310...
output:
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...
result:
wrong answer 1st numbers differ - expected: '3782', found: '2'
Subtask #5:
score: 0
Time Limit Exceeded
Test #15:
score: 0
Time Limit Exceeded
input:
20 200000 1000000 13 10 13 5 19 5 19 20 15 10 15 6 12 6 12 3 8 10 8 2 1 20 1 11 14 10 14 16 18 3 18 7 4 3 9 10 9 17 194055 154514 194055 148156 148156 115271 115271 198116 198116 179433 179433 171975 171975 196600 196600 167194 167194 185078 185078 191409 191409 163496 163496 178243 178243 154093 15...
output:
7 8 21 3 16 21 19 8 3 3 2 6 6 8 20 21 19 6 12 21 21 19 7 7 12 18 3 2 2 8 18 7 5 7 7 8 3 10 3 3 2 2 2 3 4 2 6 2 2 2 2 5 2 2 2 2 5 12 21 17 2 3 4 8 18 21 21 21 18 3 2 2 4 4 12 21 21 21 21 3 15 2 8 18 15 21 21 21 21 21 19 21 21 21 16 17 21 21 21 15 2 16 16 2 2 2 2 2 12 21 21 21 21 2 2 5 4 2 3 3 5 2 16 ...