Submission #815695

# Submission time Handle Problem Language Result Execution time Memory
815695 2023-08-08T18:54:53 Z Ozy Duathlon (APIO18_duathlon) C++17
0 / 100
1000 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define debug(a) cout << #a <<  " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define pll pair<lli,lli> 

#define MAX 100000

lli n,m,a,b,res;
vector<lli> hijos[MAX+2];
lli tam[MAX+2];

void precalcula(lli pos, lli padre){

    tam[pos] = 1;
    for(auto h : hijos[pos]) {
        if (h == padre) continue;
        precalcula(h,pos);
        tam[pos] += tam[h];
    } 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;
    rep(i,1,m) {
        cin >> a >> b;
        hijos[a].push_back(b);
        hijos[b].push_back(a);
    }
    precalcula(1,0);

    rep(act,1,n) {
        for (auto h : hijos[act]) {
            if (tam[h] > tam[act]) a = tam[1]-tam[act];
            else a = tam[h];
            
            res += a * (tam[1] -a -1); 
        }

    }

    cout << res;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 456 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 456 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 1048576 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2900 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2688 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Incorrect 2 ms 2644 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 29 ms 8388 KB Output is correct
2 Correct 28 ms 8448 KB Output is correct
3 Correct 30 ms 8392 KB Output is correct
4 Correct 30 ms 8392 KB Output is correct
5 Correct 28 ms 8368 KB Output is correct
6 Correct 40 ms 11212 KB Output is correct
7 Correct 55 ms 10628 KB Output is correct
8 Correct 32 ms 10060 KB Output is correct
9 Correct 33 ms 9452 KB Output is correct
10 Incorrect 31 ms 8396 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Runtime error 457 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 8336 KB Output is correct
2 Correct 28 ms 8312 KB Output is correct
3 Runtime error 520 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 456 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 456 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -