# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
432749 | 2021-06-18T13:05:41 Z | charterla | 기지국 (IOI20_stations) | C++14 | 867 ms | 780 KB |
#include "stations.h" #include <iostream> #include <algorithm> #include <vector> using namespace std; struct Node{ vector<int> to; int deg; }point[1005]; vector<int> labels; int num; void build(int now,int last,int p){ //cout<<now<<"<-"<<last<<":"<<p<<endl; if(p%2==0)labels[now]=num++; for(int i=0;i<point[now].to.size();i++){ int next=point[now].to[i]; if(next!=last)build(next,now,p+1); } if(p%2==1)labels[now]=num++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { num=0; labels.clear();labels.resize(n); for(int i=0;i<n;i++){ point[i].to.clear(); point[i].deg=0; } int root=0; for(int i=0;i<n-1;i++){ point[u[i]].to.push_back(v[i]); point[u[i]].deg++; if(point[u[i]].deg>point[root].deg)root=u[i]; point[v[i]].to.push_back(u[i]); point[v[i]].deg++; if(point[v[i]].deg>point[root].deg)root=v[i]; } build(root,-1,0); //for(int i=0;i<n;i++)cout<<labels[i]<<" ";cout<<endl; return labels; } int find_next_station(int s, int t, vector<int> c){ if(c.size()==1)return c[0]; bool way=true; for(int i=0;i<c.size();i++){ if(s<c[i]){ way=false; break; } } int ls=-1,rs=-1; if(way){ sort(c.begin(),c.end()); ls=c[1];rs=s; if(t<ls || t>rs)return c[0]; for(int i=1;i<c.size();i++){ ls=c[i];rs=(i==c.size()-1?s-1:c[i+1]-1); if(ls<=t && t<=rs)return c[i]; } } else{ sort(c.rbegin(),c.rend()); ls=s;rs=c[1]; if(t<ls || t>rs)return c[0]; for(int i=1;i<c.size();i++){ ls=(i==1?s+1:c[i-1]+1);rs=c[i]; if(ls<=t && t<=rs)return c[i]; } } } /* 1 5 10 0 1 1 2 1 3 2 4 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 560 ms | 508 KB | Output is correct |
2 | Correct | 493 ms | 640 KB | Output is correct |
3 | Correct | 805 ms | 500 KB | Output is correct |
4 | Correct | 701 ms | 432 KB | Output is correct |
5 | Correct | 571 ms | 520 KB | Output is correct |
6 | Correct | 489 ms | 648 KB | Output is correct |
7 | Correct | 422 ms | 516 KB | Output is correct |
8 | Correct | 3 ms | 480 KB | Output is correct |
9 | Correct | 5 ms | 448 KB | Output is correct |
10 | Correct | 2 ms | 604 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 444 ms | 768 KB | Wrong query response. |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 507 ms | 656 KB | Output is correct |
2 | Correct | 476 ms | 528 KB | Output is correct |
3 | Correct | 867 ms | 548 KB | Output is correct |
4 | Correct | 667 ms | 404 KB | Output is correct |
5 | Correct | 584 ms | 528 KB | Output is correct |
6 | Correct | 481 ms | 644 KB | Output is correct |
7 | Correct | 456 ms | 528 KB | Output is correct |
8 | Correct | 2 ms | 468 KB | Output is correct |
9 | Correct | 4 ms | 468 KB | Output is correct |
10 | Correct | 1 ms | 604 KB | Output is correct |
11 | Incorrect | 606 ms | 656 KB | Wrong query response. |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 828 ms | 520 KB | Output is correct |
2 | Correct | 653 ms | 400 KB | Output is correct |
3 | Correct | 611 ms | 644 KB | Output is correct |
4 | Correct | 3 ms | 596 KB | Output is correct |
5 | Correct | 4 ms | 596 KB | Output is correct |
6 | Correct | 2 ms | 596 KB | Output is correct |
7 | Incorrect | 576 ms | 400 KB | Wrong query response. |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 591 ms | 528 KB | Output is correct |
2 | Correct | 455 ms | 632 KB | Output is correct |
3 | Correct | 867 ms | 520 KB | Output is correct |
4 | Correct | 622 ms | 656 KB | Output is correct |
5 | Correct | 589 ms | 524 KB | Output is correct |
6 | Correct | 491 ms | 644 KB | Output is correct |
7 | Correct | 470 ms | 780 KB | Output is correct |
8 | Correct | 3 ms | 596 KB | Output is correct |
9 | Correct | 5 ms | 472 KB | Output is correct |
10 | Correct | 2 ms | 596 KB | Output is correct |
11 | Incorrect | 391 ms | 656 KB | Wrong query response. |
12 | Halted | 0 ms | 0 KB | - |