답안 #829617

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829617 2023-08-18T13:23:45 Z tolbi 철인 이종 경기 (APIO18_duathlon) C++17
0 / 100
1000 ms 1048576 KB
#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
//Sani buyuk Osman Pasa Plevneden cikmam diyor
#define author tolbi
#include <bits/stdc++.h>
using namespace std;
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define sortarr(x) sort(x.begin(), x.end())
#define sortrarr(x) sort(x.rbegin(), x.rend())
#define rev(x) reverse(x.begin(), x.end())
#define cinarr(x) for (auto &it : x) cin>>it;
#define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl;
#define tol(bi) (1LL<<((int)(bi)))
#define endl '\n'
#define int long long
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
int32_t main(){
	int T = 1;
	int tno = 0;
	while (T-(tno++)){
        deci(n);deci(m);
        vector<vector<int>> arr(n);
        for (int i = 0; i < m; ++i)
        {
            deci(u);deci(v);
            arr[u-1].push_back(v-1);
            arr[v-1].push_back(u-1);
        }
        vector<int> subsz(n);
        int ans = 0;
        auto f = [&](int node, int lnode, auto f)->void{
            subsz[node]=1;
            for (int i = 0; i < arr[node].size(); i++){
                if (arr[node][i]==lnode) continue;
                f(arr[node][i],node,f);
                ans+=subsz[arr[node][i]]*(n-subsz[arr[node][i]]-1);
                subsz[node]+=subsz[arr[node][i]];
            }
            ans+=(subsz[node]-1)*(n-subsz[node]);
        };
        f(0,-1,f);
        cout<<ans<<endl;
	}
}

Compilation message

count_triplets.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      | 
count_triplets.cpp: In instantiation of 'main()::<lambda(long long int, long long int, auto:23)> [with auto:23 = main()::<lambda(long long int, long long int, auto:23)>]':
count_triplets.cpp:49:17:   required from here
count_triplets.cpp:41:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |             for (int i = 0; i < arr[node].size(); i++){
      |                             ~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 466 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 466 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1114 ms 1048576 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 312 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Incorrect 1 ms 340 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 7052 KB Output is correct
2 Correct 75 ms 7604 KB Output is correct
3 Correct 69 ms 7588 KB Output is correct
4 Correct 87 ms 7556 KB Output is correct
5 Correct 84 ms 7660 KB Output is correct
6 Correct 58 ms 10276 KB Output is correct
7 Correct 66 ms 9756 KB Output is correct
8 Correct 82 ms 9100 KB Output is correct
9 Correct 67 ms 8604 KB Output is correct
10 Incorrect 72 ms 7592 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Runtime error 521 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 7176 KB Output is correct
2 Correct 67 ms 7064 KB Output is correct
3 Runtime error 764 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 466 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 466 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -