Hdu4858 project management bestcoder round1 B

Source: Internet
Author: User

Well .. Weak and violent fruit

When the 0 operation is performed, add V to u. You can directly add V to the point connected to u. In this way, the value of the required point is output directly.

In this case, I timed out ..


# Include <cstdio> # include <cstring> # include <cmath> # include <iostream> # include <algorithm> # include <vector> # include <queue> const int maxn = 100010; using namespace STD; vector <int> E [maxn]; int n, m, Val [maxn], C; int main () {// freopen ("in.txt ", "r", stdin); // freopen ("out.txt", "W", stdout); int T, A, B, I, Q; scanf ("% d ", & T); While (t --) {scanf ("% d", & N, & M); for (I = 0; I <= N; I ++) E [I]. clear (); memset (Val, 0, sizeof Val); While (M --) {scanf ("% d", & A, & B ); E [A]. push_back (B); E [B]. push_back (a);} scanf ("% d", & Q); While (Q --) {scanf ("% d", & ); if (A = 0) {scanf ("% d", & A, & C); for (I = 0; I <E [A]. size (); I ++) Val [E [a] [I] + = C;} else {scanf ("% d", & ); printf ("% d \ n", Val [a]) ;}} return 0 ;}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.