提出 #15025119
ソースコード 拡げる
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
∧_∧
∧_∧ (´<_` ) Welcome to My Coding Space!
( ´_ゝ`) / ⌒i @hamayanhamayan0
/ \ | |
/ / ̄ ̄ ̄ ̄/ |
__(__ニつ/ _/ .| .|____
\/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/
int N, U[201010], V[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
cin >> N;
rep(i, 0, N - 1) cin >> U[i] >> V[i];
ll ans = 0;
rep(L, 1, N + 1) ans += 1LL * L * (L + 1) / 2;
rep(i, 0, N - 1) {
if (U[i] > V[i]) swap(U[i], V[i]);
ans -= 1LL * U[i] * (N - V[i] + 1);
}
cout << ans << endl;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | F - Intervals on Tree |
| ユーザ | hamayanhamayan |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 600 |
| コード長 | 1714 Byte |
| 結果 | AC |
| 実行時間 | 46 ms |
| メモリ | 5204 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 600 / 600 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | s1.txt, s2.txt, s3.txt |
| All | 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 |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 01.txt | AC | 8 ms | 3540 KiB |
| 02.txt | AC | 3 ms | 3608 KiB |
| 03.txt | AC | 2 ms | 3472 KiB |
| 04.txt | AC | 2 ms | 3536 KiB |
| 05.txt | AC | 2 ms | 3532 KiB |
| 06.txt | AC | 2 ms | 3544 KiB |
| 07.txt | AC | 1 ms | 3636 KiB |
| 08.txt | AC | 2 ms | 3528 KiB |
| 09.txt | AC | 2 ms | 3532 KiB |
| 10.txt | AC | 2 ms | 3556 KiB |
| 11.txt | AC | 40 ms | 5172 KiB |
| 12.txt | AC | 46 ms | 5096 KiB |
| 13.txt | AC | 39 ms | 5096 KiB |
| 14.txt | AC | 42 ms | 5040 KiB |
| 15.txt | AC | 34 ms | 5148 KiB |
| 16.txt | AC | 35 ms | 5104 KiB |
| 17.txt | AC | 33 ms | 4892 KiB |
| 18.txt | AC | 19 ms | 4192 KiB |
| 19.txt | AC | 39 ms | 5144 KiB |
| 20.txt | AC | 37 ms | 5088 KiB |
| 21.txt | AC | 39 ms | 5204 KiB |
| 22.txt | AC | 39 ms | 5204 KiB |
| 23.txt | AC | 36 ms | 5148 KiB |
| s1.txt | AC | 2 ms | 3584 KiB |
| s2.txt | AC | 2 ms | 3556 KiB |
| s3.txt | AC | 2 ms | 3580 KiB |