Submission #15068087


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i, x) for (ll i = 0; i < (x); i++)
#define chmax(x, a)  do { x = max(x, a); } while(0)

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


int main(void) {
  ll N;
  cin >> N;
  ll V = 0, E = 0;
  rep(i, N) {
    V += (i + 1) * (N - i);
  }
  rep(i, N-1) {
    ll u, v;
    cin >> u >> v;
    u--, v--;
    if (u > v) swap(u, v);
    E += (u + 1) * (N - v);
  }
  cout << (V - E) << endl;
  return 0;
}

Submission Info

Submission Time
Task F - Intervals on Tree
User bobuhiro11
Language C++ (GCC 9.2.1)
Score 600
Code Size 499 Byte
Status
Exec Time 96 ms
Memory 3612 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt
All 600 / 600 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt 8 ms 3448 KB
02.txt 2 ms 3448 KB
03.txt 2 ms 3524 KB
04.txt 2 ms 3576 KB
05.txt 2 ms 3436 KB
06.txt 2 ms 3564 KB
07.txt 2 ms 3560 KB
08.txt 2 ms 3440 KB
09.txt 2 ms 3584 KB
10.txt 2 ms 3612 KB
11.txt 74 ms 3560 KB
12.txt 88 ms 3612 KB
13.txt 86 ms 3436 KB
14.txt 90 ms 3564 KB
15.txt 79 ms 3436 KB
16.txt 96 ms 3576 KB
17.txt 77 ms 3440 KB
18.txt 41 ms 3444 KB
19.txt 89 ms 3440 KB
20.txt 94 ms 3564 KB
21.txt 93 ms 3520 KB
22.txt 91 ms 3524 KB
23.txt 86 ms 3444 KB
s1.txt 5 ms 3404 KB
s2.txt 2 ms 3388 KB
s3.txt 2 ms 3564 KB