# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
538146 | Pherokung | Teleporters (IOI08_teleporters) | C++17 | 1093 ms | 43240 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int n,m,a[2000005],b[2000005],tp[2000005],ty[2000005],num[2000005],pos,ans,cnt;
priority_queue<int> pq;
queue<int> q;
vector<int> v;
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
scanf("%d%d",&a[i],&b[i]);
tp[a[i]] = b[i];
tp[b[i]] = a[i];
ty[a[i]] = i;
ty[b[i]] = i;
}
ans = 0;
pos = 1;
while(pos <= 2000001){
if(tp[pos] != 0){
num[ty[pos]]++;
pos = tp[pos] + 1;
}
else pos += 1;
}
for(int i=1;i<=n;i++){
ans += num[i];
if(num[i] == 1){
q.push(i);
}
}
while(!q.empty()){
int ind = q.front();
q.pop();
pos = a[ind] + 1;
v.clear();
while(pos <= b[ind] - 1){
if(tp[pos] != 0){
v.push_back(ty[pos]);
num[ty[pos]]++;
pos = tp[pos] + 1;
}
}
pq.push(v.size() + 3);
for(auto x : v) if(num[x] == 1) q.push(x);
}
while(!pq.empty() && m > 0){
ans += pq.top();
pq.pop();
m--;
}
ans += 4 * (m/2) + m % 2;
printf("%d",ans);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |