QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#89870 | #5110. Splitstream | _skb_# | WA | 2ms | 3336kb | C++14 | 1.9kb | 2023-03-21 17:41:56 | 2023-03-21 17:41:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n,q,m;
cin>>m>>n>>q;
vector<ll> sz(4*n+1);
vector<pair<int,int>> par(4*n+1);
sz[1]=m;
for(int i=0;i<n;i++){
char p;
int x,y,z;
cin>>p>>x>>y>>z;
if(p=='S'){
par[y]={x,-1};
par[z]={-1,x};
sz[y]=(sz[x]+1)/2;
sz[z]=sz[x]/2;
}
else{
par[z]={x,y};
sz[z]=sz[x]+sz[y];
}
}
while(q--){
ll u,k;
cin>>u>>k;
int f=1;
while(u!=1){
int x=par[u].first;
int y=par[u].second;
if(k>sz[u]){
f=0;
break;
}
if(x==-1){
u=y;
k=2*k;
}
else if(y==-1){
u=x;
k=2*k-1LL;
}
else{
ll a=sz[x];
ll b=sz[y];
if(k>a+b){
f=0;
break;
}
if(a>=b){
if(k<=2*b){
if(k%2) u=x;
else u=y;
k=(k+1)/2;
}
else{
u=x;
k=k-b;
}
}
else{
if(k<=2*a){
if(k%2) u=x;
else u=y;
k=(k+1)/2;
}
else{
u=y;
k=k-a;
}
}
}
}
if(k>m) f=0;
if(!f) cout<<"none\n";
else cout<<k<<"\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3336kb
input:
5 8 26 M 8 9 13 S 2 4 5 S 1 2 3 M 6 5 8 S 4 9 10 S 10 14 15 S 3 6 7 S 7 11 12 2 3 2 4 3 2 3 3 4 2 4 3 5 1 5 2 6 1 6 2 7 1 7 2 8 2 8 3 9 1 9 2 10 1 10 2 11 1 11 2 12 1 13 3 13 4 14 1 14 2 15 1
output:
5 none 4 none none none none none 2 none 4 none none none none none none none 4 none none none none none none none
result:
wrong answer 5th lines differ - expected: '5', found: 'none'