답안 #413099

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
413099 2021-05-28T08:45:16 Z BJoozz 기지국 (IOI20_stations) C++14
0 / 100
4 ms 456 KB
#include "stations.h"
#define X first
#define Y second
#define pb push_back
#include<bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int randint(int l,int r){
    return uniform_int_distribution < int > (l,r) (rng);
}
///shuffle(a.begin(), a.end(), rng)
//#define int long long
const int MAX=1000+4,M2=5e5+3;
void maxx(int &a,int b){if(b>a) a=b;}
void minn(int &a,int b){if(b<a) a=b;}
template <class X, class Y>
bool cmin(X &a, const Y &b) {
    return a > b ? a = b, 1 : 0;
}
bool cmax(int &a,int b){
    if(b>a){a=b;return 1;} else return 0;
}
typedef pair < int, int > ii;

vector < int > pr[MAX];
struct qb{
    int a,b;
    int c;
    qb(int a,int b,int c): a(a),b(b),c(c) {};
};
int in[MAX];
int tim;
void dfs(int v,int pa,bool h){
    if(!h) in[v]=tim++;
    for(int u:pr[v])if(u!=pa)
        dfs(u,v,!h);
    if(h) in[v]=tim++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);
	for (int i = 0; i < n-1; i++){
        pr[u[i]].pb(v[i]);
        pr[v[i]].pb(u[i]);
	}
	//dfs(0,0,0);

	for (int i = 0; i < n; i++) {
		labels[i] = in[i];
	}
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    //cout<<s<<' '<<t<<'\n';
    //for(int u:c) cout<<u<<'\n';

	if(s<c[0]){
        if(t<s) return c.back();
        int b=0,e=int(c.size())-2,an=c.back();
        while(b<=e){
            int m=b+e>>1;
            if(t<=c[m]){
                an=c[m];
                b=m+1;
            }
            else e=m-1;
        }
        return an;
	}
	else{
        if(t>s) return c[0];
        int b=1,e=int(c.size())-1,an=c[0];
        while(b<=e){
            int m=b+e>>1;
            if(t>=c[m]){
                an=c[m];b=m+1;

            }
            else e=m-1;
        }
        //cout<<"sp "<<an<<'\n';
        return an;
	}
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:61:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   61 |             int m=b+e>>1;
      |                   ~^~
stations.cpp:74:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   74 |             int m=b+e>>1;
      |                   ~^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 456 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 436 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 456 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 200 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 424 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -