# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
914285 | 2024-01-21T14:16:23 Z | Ludissey | 봉쇄 시간 (IOI23_closing) | C++17 | 1000 ms | 37068 KB |
#include <bits/stdc++.h> #include "closing.h" using namespace std; #define int long long #define sz(a){ return (int)a.size(); } const int INF=1e9; vector<vector<pair<int,int>>> edges; vector<int> dstX; vector<int> dstY; signed max_score(signed N, signed rootX, signed rootY, long long K, std::vector<signed> U, std::vector<signed> V, std::vector<signed> W){ vector<pair<int,int>> singl; vector<pair<int,int>> doubl; edges.clear(); dstX.clear(); edges.resize(N); dstX.resize(N); dstY.resize(N); singl.resize(N); doubl.resize(N); for (int i = 0; i < N-1; i++) { edges[V[i]].push_back({U[i], W[i]}); edges[U[i]].push_back({V[i], W[i]}); } vector<bool> visited(N); queue<pair<int,int>> queue; queue.push({rootX,0}); while(!queue.empty()){ int x=queue.front().first,w=queue.front().second; queue.pop(); if(visited[x]) continue; visited[x]=true; dstX[x]=w; for (auto u: edges[x]) queue.push({u.first, u.second+w}); } visited.clear(); visited.resize(N); queue.push({rootY,0}); while(!queue.empty()){ int x=queue.front().first,w=queue.front().second; queue.pop(); if(visited[x]) continue; visited[x]=true; dstY[x]=w; for (auto u: edges[x]) queue.push({u.first, u.second+w}); } for (int i = 0; i < N; i++) singl[i]={min(dstY[i], dstX[i]),i}; for (int i = 0; i < N; i++) doubl[i]={dstY[i]+dstX[i], i}; int res=K; int sum=0; while(!singl.empty()){ sort(singl.begin(),singl.end()); sort(doubl.begin(),doubl.end()); if(singl.size()==1||(res-(singl[0].first+singl[1].first)<0&&(doubl.empty()||(res-doubl[0].first)<0))){ if(res-singl[0].first>=0) sum++; break; } if(doubl.empty() || singl[0].first+singl[1].first<doubl[0].first){ res-=singl[0].first+singl[1].first; if(doubl.empty()) { singl.erase(singl.begin()); singl.erase(singl.begin()); continue; } for (int i = 0; i < doubl.size(); i++) { if(doubl[i].second==singl[0].second||doubl[i].second==singl[1].second) { singl.push_back({max(dstY[doubl[i].second], dstX[doubl[i].second]),doubl[i].second}); doubl.erase(doubl.begin()+i); } } singl.erase(singl.begin()); singl.erase(singl.begin()); }else{ res-=doubl[0].first; for (int i = 0; i < singl.size(); i++) { if(singl[i].second==doubl[0].second) { singl.erase(singl.begin()+i); break; } } doubl.erase(doubl.begin()); } sum+=2; } return (int)sum; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1101 ms | 37068 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | 1st lines differ - on the 1st token, expected: '3', found: '4' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | 1st lines differ - on the 1st token, expected: '3', found: '4' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | 1st lines differ - on the 1st token, expected: '3', found: '4' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |