Description
There is an apple tree outside of kaka’s house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been carefully nurturing the big apple tree.
The tree has N forks which are connected by branches. Kaka numbers the forks by 1 to N and the root is always numbered by 1. Apples will grow on the forks and two apple won’t grow on the same fork. kaka wants to know how many apples are there in a sub-tree, for his study of the produce ability of the apple tree.
The trouble is that a new apple may grow on an empty fork some time and kaka may pick an apple from the tree for his dessert. Can you help kaka?
Input
The first line contains an integer N (N ≤ 100,000) , which is the number of the forks in the tree.
The following N – 1 lines each contain two integers u and v, which means fork u and fork v are connected by a branch.
The next line contains an integer M (M ≤ 100,000).
The following M lines each contain a message which is either
“C x” which means the existence of the apple on fork x has been changed. i.e. if there is an apple on the fork, then Kaka pick it; otherwise a new apple has grown on the empty fork.
or
“Q x” which means an inquiry for the number of apples in the sub-tree above the fork x, including the apple (if exists) on the fork x
Note the tree is full of apples at the beginning
Output
For every inquiry, output the correspond answer per line.
Sample Input
3
1 2
1 3
3
Q 1
C 2
Q 1
Sample Output
3
2
Source
POJ Monthly
波比源码 » POJ3321—Apple Tree(树状数组)
90 评论
评论已关闭
buy levaquin 250mg without prescription levaquin brand
order dutasteride sale flomax 0.2mg pills zofran oral
aldactone 100mg without prescription cost valtrex fluconazole cost
ampicillin over the counter order cephalexin 500mg pills erythromycin online order
sildenafil generic buy nolvadex 20mg online cheap robaxin 500mg oral
buy suhagra 100mg estradiol 2mg over the counter buy estradiol 1mg without prescription
order lamictal 200mg pills minipress 1mg drug order generic retin cream
generic tadalis tadacip 10mg drug order generic voltaren
coupon for cialis cialis 20mg lowest price viagra 100mg us
buy prednisone 5mg generic cialis availability cheap viagra generic
tadalafil kaufen ohne rezept tadalafil 20mg generika viagra 100mg generika rezeptfrei kaufen
order isotretinoin 40mg without prescription order isotretinoin 20mg without prescription buy ivermectin 12mg
doxycycline for sale online buy generic doxycycline 100mg lasix 100mg over the counter
order altace generic astelin 10ml usa buy azelastine online cheap
clonidine oral clonidine 0.1mg cheap buy spiriva 9 mcg without prescription
order buspar 5mg sale buy amiodarone generic oxybutynin 2.5mg pills
fosamax 35mg price alendronate for sale online order famotidine generic
purchase benicar pill olmesartan 10mg for sale diamox 250 mg us
order prograf 5mg without prescription order tacrolimus sale ursodiol pills
isosorbide 40mg cost lanoxin 2250 mg sale micardis 80mg ca
zoloft online buy escitalopram 20mg sale sildenafil fast shipping
tadalafil 20mg uk order tadalafil 20mg generic usa pharmacy viagra
order medroxyprogesterone 10mg online cheap purchase cyproheptadine generic cost cyproheptadine
provigil 200mg cheap canada online pharmacies ivermectin topical
brand accutane 10mg accutane 10mg for sale prednisone 20mg sale
cialis price costco buy cialis 10mg pill sildenafil 50mg sale
oral furosemide order lasix for sale order hydroxychloroquine 200mg sale
brand cialis order betamethasone 20 gm online anafranil 50mg ca
brand sildenafil 50mg order sildenafil 50mg sale buy lisinopril 5mg generic
linezolid 600 mg pill best casinos best online casino for real money
prilosec 10mg price online blackjack live dealer roulette online real money
brand lopressor levitra 10mg price vardenafil 20mg price
write my paper for me casino online usa gambling casino
buy a dissertation cheap essays online buy sildenafil 50mg
buy tadalafil 5mg sale cialis 20 sildenafil 50mg price
purchase aristocort generic desloratadine 5mg tablet desloratadine 5mg usa
order priligy 90mg generic purchase synthroid online cheap purchase levothyroxine
buy allopurinol 300mg without prescription purchase rosuvastatin sale cheap ezetimibe 10mg
order methotrexate 5mg online buy warfarin generic cheap metoclopramide 20mg
generic motilium sumycin 500mg without prescription cyclobenzaprine without prescription
order ozobax online cheap baclofen 10mg usa toradol 10mg sale
ranitidine 150mg pill order mobic without prescription buy celecoxib 200mg without prescription
cialis 20mg tablet order tadalafil 20mg for sale cipro over the counter
order zocor for sale order zocor 10mg sale buy propecia generic
purchase diflucan generic viagra uk cheap viagra pill
slots games slot games online order tadalafil for sale
essay writers online stromectol 12mg price stromectol how much it cost
order sildenafil 50mg pill buy generic sildenafil 100mg tadalafil for women
online blackjack for real money best online casino usa purchase provigil without prescription
order furosemide 100mg order lasix 100mg order plaquenil 200mg
order fildena sale sildenafil 100mg sale rhinocort order online
tretinoin cream canada retin over the counter order avanafil without prescription
lamisil 250mg canada brand terbinafine trimox 500mg cost
naprosyn 250mg price oral prevacid prevacid 30mg over the counter
proventil 100mcg for sale buy proventil 100mcg for sale cipro 500mg for sale
oral actos 30mg pioglitazone 30mg usa sildenafil 100mg pills for sale
montelukast drug sildenafil 100mg sale viagra 100mg sale
buy cialis 5mg pills Brand cialis for sale cheap tadalafil
casino free spins no deposit best online casinos that payout slot game
buy nifedipine 10mg sale purchase nifedipine sale order allegra for sale
ramipril 5mg over the counter purchase arcoxia pill order arcoxia 120mg sale
doxycycline 100mg cost albuterol drug cleocin without prescription
order mesalamine 400mg pills mesalamine online buy purchase irbesartan pills
acetazolamide for sale diamox tablet order imuran pills
clobetasol for sale cordarone canada cordarone 100mg cheap
fosamax 70mg pill order ibuprofen 400mg online cheap ibuprofen usa
buy priligy for sale cheap domperidone 10mg oral domperidone 10mg
order generic pamelor order paroxetine 10mg online cheap order paxil online cheap
pepcid usa buy pepcid purchase remeron pill
doxycycline 100mg uk cost chloroquine 250mg buy medrol canada
buy requip 2mg pill buy ropinirole generic buy trandate generic
cialis 5mg sale Cialis overnight shipping order viagra sale
minocycline 100mg us neurontin 600mg usa buy hytrin 1mg generic
order tadalafil pill Buy discount cialis online blue pill for ed
glycomet online order order generic verapamil 240mg tamoxifen cheap
purchase provigil online cheap order stromectol 12mg for sale promethazine 25mg for sale
order generic prednisone 20mg order isotretinoin 10mg pill order amoxicillin online
can i buy ed pills over the counter fildena 50mg pill order propecia 1mg online cheap
ivermectin 12mg stromectol cheap erectile dysfunction buy prednisone 10mg generic
ondansetron order sulfamethoxazole tablet buy bactrim 480mg online
modafinil 100mg over the counter order modafinil 200mg for sale metoprolol 100mg oral
prednisolone 5mg drug oral lasix 40mg order lasix pill
cost doxycycline 200mg zovirax pills buy acyclovir 400mg for sale
buy azathioprine 50mg without prescription micardis order order generic naprosyn 500mg
ditropan 5mg us brand trileptal 600mg buy trileptal sale
cefdinir online buy prevacid 30mg online pantoprazole 20mg pills
zocor medication promethazine for sale sildenafil 100mg tablets
dapsone 100 mg brand tenormin canada buy tenormin tablets
alfuzosin canada diltiazem ca purchase diltiazem pills
sildenafil 100mg pills for sale usa viagra overnight cialis daily cost