제출 #1320713

#제출 시각아이디문제언어결과실행 시간메모리
1320713yeyso2이주 (IOI25_migrations)C++20
0 / 100
28 ms872 KiB
#include "migrations.h" using namespace std; #include <bits/stdc++.h> vector<vector<int>> adj; vector<int> dist_from_0; void dfs(int u, vector<int>& dist){ for(int v : adj[u]){ dist[v] = dist[u] + 1; dfs(v, dist); } } int furtherest_node_from(int u){ vector<int> dist(adj.size(), 0); int max_dist = 0; int far = 0; dfs(u, dist); for(int iz = 0; iz < dist_from_0.size(); iz ++){ if(dist[iz] > max_dist){ max_dist = dist_from_0[iz]; far = iz; } } return far; } int ipow(int base, int exp) { int result = 1; while (exp > 0) { if (exp & 1) result *= base; base *= base; exp >>= 1; } return result; } int furtherest = 0; int end_1; int end_2; int send_message(int N, int i, int Pi) { if(i == 1){ adj.resize(N); dist_from_0.resize(N, 0); adj[Pi].push_back(1); return 0; } adj[Pi].push_back(i); if(i < 9997) return 0; if(i == 9997){ end_1 = furtherest_node_from(0); end_2 = furtherest_node_from(end_1); if(end_1 > end_2){ int temp = end_1; end_1 = end_2; end_2 = temp; } return end_1; } if(i == 9998){ // return end_2; } if(i == 9999){ int new_end1 = furtherest_node_from(0); int new_end2 = furtherest_node_from(new_end1); if(new_end1 > new_end2){ int temp = new_end1; new_end1 = new_end2; new_end2 = temp; } if(end_1 != new_end1){ return new_end1; } if(end_2 != new_end2){ return new_end2 + 10000; } return 20000; } return 0; } std::pair<int, int> longest_path(std::vector<int> S) { if(S.back() == 20000){ return {S[9997], S[9998]}; } if(S.back() < 10000){ return {S.back(), S[9998]}; } return {S[9999], S.back() - 10000}; } /* g++ -std=gnu++20 -Wall -O2 -pipe -static -g -o migrations grader.cpp migrations.cpp 6 0 0 2 2 3 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...