Problem:
Problem G:
挨拶の多い本屋さん
なつめは大のねこ好きである。なつめはある日、いつも親しくしている野良ねこたちから、ねこたちが開いている不思議な本屋に行こうと誘われた。その本屋ではたくさんのねこの写真が載った本が売られていると聞き、なつめは喜んでついていくことにした。
なつめは知らなかったのだが、ねこたちに連れられていった本屋は全国にチェーン店を持つ有名店であった。その店ではしっかりとした店員用マニュアルが用意されており、どの店舗でも店員の行動が統一されている。以下はそのマニュアルからの抜粋である。
店員からユークリッド距離10以内のドアからお客様が入店された際には、
X
秒間かけて大声で「いらっしゃいませこんにちは」といわなければならない。
ユークリッド距離50以内の他の店員が「いらっしゃいませこんにちは」と言っているのを聞いた店員は、その「いらっしゃいませこんにちは」の発声終了時に「いらっしゃいませこんにちは」と
X
秒かけて大声で復唱しなければならない。ただし、この復唱の発声開始時から過去
Y
秒以内に、別の「いらっしゃいませこんにちは」を発声完了していた店員は、復唱してはならない。
X
,
Y
, 客の位置、店員の配置が与えられるので、客が入ってから店が静かになるまで何秒かかるか計算せよ。復唱が鳴り止まない場合は、"You're always welcome!"と出力せよ。
Input
入力の1行目には、店員の数
N
、およびマニュアルに書かれている
X
,
Y
がそれぞれ1つの空白文字で区切られて与えられる。2行目はなつめが入店する位置であり、それに続く
N
行は
N
人の店員の位置を表す座標である。それぞれの位置は
x
,
y
座標を1つの空白文字で区切って与えられ、各数値とも0以上1000以下の整数で与えられる。また、1 <=
N
<= 1000, 1 <=
X
,
Y
<= 100を満たす。
Output
復唱が鳴り止む場合は客が入店してから静かになるまでの時間を、鳴り止まない場合は "You're always welcome!" を1行に出力せよ。
Notes on Submission
上記形式で複数のデータセットが与えられます。入力データの 1 行目にデータセットの数が与えられます。各データセットに対する出力を上記形式で順番に出力するプログラムを作成して下さい。
Sample Input
4
3 3 5
0 0
10 0
40 40
40 90
4 5 10
100 100
50 100
50 150
100 50
100 150
4 60 10
100 100
90 100
110 100
100 90
100 110
4 60 10
100 100
80 100
110 100
100 80
100 110
Output for the Sample Input
9
0
60
You're always welcome!

Submitted solutions:

code_snippet: #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Point{
	double x,y;
};

int N,X,Y,pre_time[1000];
Point customer,point[1000];
bool near_customer[1000];
bool check[1000];
vector<int> NEAR[1000];


double calc_dist(Point a,Point b){
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

void func(){

	scanf("%d %d %d",&N,&X,&Y);

	for(int i = 0; i < N; i++)NEAR[i].clear();

	scanf("%lf %lf",&customer.x,&customer.y);

	for(int i = 0; i < N; i++){
		scanf("%lf %lf",&point[i].x,&point[i].y);
		near_customer[i] = (calc_dist(point[i],customer) <= 10.0);
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++){
			if(calc_dist(point[i],point[k]) <= 50.0){
				if(i != k)NEAR[i].push_back(k);
			}
		}
	}

	int ans;
	vector<int> V,NEXT;

	for(int i = 0; i < N; i++){
		if(near_customer[i]){
			pre_time[i] = X;
			V.push_back(i);
		}else{
			pre_time[i] = -1;
		}
	}

	if(V.size() == 0){
		printf("0\n");
		return;
	}

	ans = X;

	while(true){

		for(int i = 0; i < N; i++)check[i] = false;
		for(int i = 0; i < V.size(); i++){
			for(int k = 0; k < NEAR[V[i]].size(); k++){
				check[NEAR[V[i]][k]] = true;
			}
		}
		for(int i = 0; i < N; i++){
			if(check[i]){
				if(pre_time[i] == -1){
					pre_time[i] = ans+X;
					NEXT.push_back(i);
				}else if(pre_time[i] != -1 && ans-pre_time[i] > Y){
					printf("You're always welcome!\n");
					return;
				}
			}
		}
		if(NEXT.size() == 0)break;
		V.clear();
		for(int i = 0; i < NEXT.size(); i++)V.push_back(NEXT[i]);
		NEXT.clear();
		ans += X;
	}

	printf("%d\n",ans);
}

int main(){

	int case_num;
	scanf("%d",&case_num);

	for(int i = 0; i < case_num; i++)func();

	return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 7076
final_rank: 14

code_snippet: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

int main() {
	int T;cin>>T;
	while (T--) {
		int N,X,Y;cin>>N>>X>>Y;
		int in_x, in_y; cin >> in_x >> in_y;
		vector<pair<int,int>>ps;
		for (int i = 0; i < N; ++i) {
			int x,y;cin>>x>>y;
			ps.emplace_back(x,y);
		}
		vector<vector<int>>edges(N);
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				if (i != j) {
					int dis=(ps[i].first-ps[j].first)*(ps[i].first-ps[j].first)+
						(ps[i].second-ps[j].second)*(ps[i].second-ps[j].second);
					if (dis <= 2500) {
						edges[i].push_back(j);
					}
				}
			}
		}
		int time=0;
		vector<int>pres(N, -1000);
		vector<int>nowsays;
		for (int i = 0; i < N; ++i) {
			int dis=(ps[i].first-in_x)*(ps[i].first-in_x)+(ps[i].second-in_y)*(ps[i].second-in_y);
			if (dis <= 100) {
				nowsays.push_back(i);
				pres[i]=-1;
			}
		}
		int w_count=(Y)/X;
		bool ok = true;
		while (!nowsays.empty()) {
			vector<int>flags(N);
			for (auto ns : nowsays) {
				for (auto e : edges[ns]) {
					flags[e]=true;
				}
			}
			vector<int>nextsays;
			for (int i = 0; i < N; ++i) {
				if (flags[i]) {
					if (pres[i] == -1000) {
						nextsays.push_back(i);
						pres[i]=time;
					}else{
						if (pres[i] + w_count+1 < time) {
							ok=false;
						}else{
						}
					}
				}
			}
			nowsays=nextsays;
			time++;
			if(!ok)break;
		}
		if (ok) {
			cout<<time*X<<endl;
		}else{
			cout<< "You're always welcome!"<<endl;
		}

	}
	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 6816
final_rank: 13

code_snippet: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int q;
	cin>>q;
	while(q--){
		int n,X,Y;
		cin>>n>>X>>Y;
		vvi G(n);
		int x,y;cin>>x>>y;
		vi a(n),b(n);
		rep(i,n)cin>>a[i]>>b[i];
		rep(i,n)rep(j,n)if(i!=j&&hypot(a[i]-a[j],b[i]-b[j])<EPS+50){
			G[i].pb(j);
			G[j].pb(i);
		}
		vi in(n,-2000);
		int out=0;
		rep(i,n)if(hypot(x-a[i],y-b[i])<EPS+10)in[i]=X,out=X;
		while(1){
			vi ne=in;
			int t=out;
			rep(i,n)if(in[i]==t){
				rep(j,G[i].size())if(in[i]-Y>in[G[i][j]]){
					out=ne[G[i][j]]=t+X;
				}
			}
			if(in==ne){
				cout<<out<<endl;
				goto end;
			}
			if(out>1e5)break;
			in=ne;
		}
		cout<<"You're always welcome!"<<endl;
		end:;
	}
}
accuracy: 1
time_ms: 220
memory_kb: 9188
final_rank: 19

code_snippet: #include <bits/stdc++.h>
  
using namespace std;
  
#define MAX 1010
  
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y) : x(x),y(y) {}
};
  
int N,X,Y;
vector<int> G[MAX];
  
double getDist(Point &a,Point &b){
    return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
  
void init(){
    for(int i = 0 ; i < MAX ; i++){
	G[i].clear();
    }  
}
  
void solve(){
    int d[MAX] = {0};
    queue<int> Q; Q.push(0);
    bool can = true;
   
    while(!Q.empty()){
	int v = Q.front(); Q.pop();
	for(int i = 0 ; i < (int)G[v].size() ; i++){
	    int to = G[v][i];
	    if(d[to] == 0){
		d[to] = d[v] + 1;
		if(v > 0 && X > Y) can = false;
		Q.push(to);
	    }
	}
    }
   
    if(can){
	cout << *max_element(d+1,d+N+1)*X << endl;
    }else{
	cout << "You're always welcome!" << endl;
    }
}
  
int main(){
    int Tc;
    cin >> Tc;
    while(Tc--){
	init();
	Point sp;
	vector<Point> p;
	cin >> N >> X >> Y;
	cin >> sp.x >> sp.y;
	p.resize(N);
	for(int i = 0 ; i < N ; i++){
	    cin >> p[i].x >> p[i].y;
	    if(getDist(sp,p[i]) <= 10){
		G[0].push_back(i+1);
	    }
	}
	for(int i = 0 ; i < N ; i++){
	    for(int j = 0 ; j < N ; j++){
		if(i == j) continue;
		if(getDist(p[i],p[j]) <= 50){
		    G[i+1].push_back(j+1);
		}
	    }
	}
	solve();
    }
    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 7096
final_rank: 15

code_snippet: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;

const int INF = 1 << 30;
const int DD = 10;
const int PD = 50;

/* typedef */

typedef vector<int> vi;

template <typename T>
struct Pt {
  T x, y;

  Pt() {}
  Pt(T _x, T _y) : x(_x), y(_y) {}
  Pt(const Pt& pt) : x(pt.x), y(pt.y) {}

  bool operator==(const Pt pt) const { return x == pt.x && y == pt.y; }
  Pt<T> operator+(const Pt pt) const { return Pt<T>(x + pt.x, y + pt.y); }
  Pt<T> operator-() const { return Pt<T>(-x, -y); }
  Pt<T> operator-(const Pt pt) const { return Pt<T>(x - pt.x, y - pt.y); }
  Pt<T> operator*(T t) const { return Pt<T>(x * t, y * t); }
  Pt<T> operator/(T t) const { return Pt<T>(x / t, y / t); }
  T dot(Pt v) const { return x * v.x + y * v.y; }
  T cross(Pt v) const { return x * v.y - y * v.x; }
  Pt<T> mid(const Pt pt) { return Pt<T>((x + pt.x) / 2, (y + pt.y) / 2); }
  T d2() { return x * x + y * y; }
  double d() { return sqrt(d2()); }

  Pt<T> rot(double th) {
    double c = cos(th), s = sin(th);
    return Pt<T>(c * x - s * y, s * x + c * y);
  }

  Pt<T> rot90() { return Pt<T>(-y, x); }

  bool operator<(const Pt& pt) const {
    return x < pt.x || (x == pt.x && y < pt.y);
  }

  void print(string format) {
    printf(("(" + format + ", " + format + ")\n").c_str(), x, y);
  }
  void print() { print("%.6lf"); }
};

typedef Pt<int> pt;

/* global variables */

int n, x, y;
pt dr, pts[MAX_N];
vi nbrs[MAX_N];
int dists[MAX_N];
bool used[MAX_N];

/* subroutines */

/* main */

int main() {
  int tn;
  cin >> tn;

  while (tn--) {
    cin >> n >> x >> y;
    cin >> dr.x >> dr.y;
    for (int i = 0; i < n; i++) cin >> pts[i].x >> pts[i].y;

    for (int i = 0; i < n; i++) {
      dists[i] = -INF;
      nbrs[i].clear();
    }
    
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++)
	if ((pts[j] - pts[i]).d2() <= PD * PD) {
	  nbrs[i].push_back(j);
	  nbrs[j].push_back(i);
	}

    memset(used, false, sizeof(used));
    
    queue<int> q;
    for (int i = 0; i < n; i++)
      if ((pts[i] - dr).d2() <= DD * DD)
	q.push(i), dists[i] = x, used[i] = true;

    int max_d = 0;
    bool always = false;
    
    while (! q.empty()) {
      int u = q.front(); q.pop();
      int ud = dists[u];
      if (max_d < ud) max_d = ud;

      int nvd = ud + x;
      vi& nbru = nbrs[u];

      for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
	int& v = *vit;

	if (dists[v] < ud - y) {
	  if (used[v]) {
	    always = true;
	    break;
	  }

	  q.push(v);
	  dists[v] = nvd;
	  used[v] = true;
	}
      }

      if (always) break;
    }
    //cout << always << ' ' << max_d << endl;

    if (always)
      cout << "You're always welcome!" << endl;
    else
      cout << max_d << endl;
  }

  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 5340
final_rank: 5

code_snippet: #include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int dist( pii a,pii b){
    int y=a.first-b.first;
    int x=a.second-b.second;
    
    return (x*x + y*y);
}



int main(){
    int loop;
    cin>>loop;
    rep(i,loop){
        
        int n,x,y;
        cin>>n>>x>>y;
        
        pii start;
        cin>>start.second>>start.first;
        
        pii cat[2000];
        rep(i,n){
            cin>>cat[i].second>>cat[i].first;
        }
        
//        if( x>=y ){cout<<"You're always welcome!"<<endl;continue;}
        
        vi connect[2000];
        
        rep(i,n){
            rep(j,n){
                if(i!=j){
                    if( dist(cat[i],cat[j])<=2500 ){
                        connect[i].pb(j);
                        connect[j].pb(i);
                    }
                }
            }
        }
        
        int used[2000];
        rep(i,2000)used[i]=-9999;

        queue<int> que;
        
        rep(i,n){
            if( dist(start,cat[i])<=100 ){
                que.push(i);
                used[i]=x;
            }
        }
        int term=0;
        if( que.size() )term++;
        
        int now=0;
        int times=0;
        while(que.size()){
            times++;
            now=term*x;
            int len=que.size();
            rep(i,len){
                int qf=que.front();
                for( int j=0;j<connect[qf].size();j++){
                    int connected = connect[qf][j];
                    if( now-used[ connected ]>y ){
                        que.push( connected );
                        used[ connected ] = now+x;
                    }
                }
                que.pop();
            }
            if(times>2000)break;
            term++;
        }
        
//        while( que.size() ){
//            now=term*x;
//            bool flag=true;
//            times++;
//            int qf=que.front();
//            for( int i=0;i<connect[qf].size();i++ ){
//                int connected = connect[qf][i];
//                if( now-used[ connected ]>y ){  // >= ?
//                    if(flag)term++;
//                    flag=false;
//                    que.push( connected );
//                    used[ connected ]=now+x;    // now+x-1 ?
//                }
//            }
//            que.pop();
//            if(times>10000)break;
//        }
        
        
        if(times>2000)cout<<"You're always welcome!"<<endl;
        else cout<<now<<endl;
    }
}
accuracy: 1
time_ms: 60
memory_kb: 9432
final_rank: 17

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int N,T;
 
vector<int> G[1111];
bool F[1111][1111];
int X,Y;
 
int dub(int a){ return a*a; }
int abs( P a, P b ){
  return dub(a.first-b.first)+dub(a.second-b.second);
}
 
int main(){
  cin >> T;
  while( T-- ){
    for(int i=0;i<N;i++) G[i].clear();
    cin >> N >> X >> Y;
    P s;
    cin >> s.first >> s.second;
    P v[1111];
    for(int i=0;i<N;i++)
      cin>> v[i].first >> v[i].second;    
    queue<int> q;
    int H[1111] = {};
    for(int i=0;i<N;i++){
      if( abs( s, v[i] ) <= 10*10 ) {
        q.push( i );
        H[i] = X;
      }
      for(int j=i+1;j<N;j++){       
        if( abs(v[i],v[j]) <= 50*50 ){
          G[i].push_back( j );
          G[j].push_back( i );
        }
      }
    }
     
    memset(F,0,sizeof(F));
    int res = 0;
    while( !q.empty() ){
      int p = q.front(); q.pop();
      int time = H[p];
      res = max( res, time );
      //  cout<< p << " "<< time << endl;
      for(int i=0;i<(int)G[p].size();i++){
        int to =G[p][i];
        if( H[to] > 0 && H[to] >= time - Y ) continue;
        if( F[i][to] ){
          res = -1; goto end;
        }
        F[i][to] = true;
        q.push( to );
        H[to] = time + X;
      }
    }
  end:;
    if( res == -1 ) cout << "You're always welcome!" << endl;
    else cout << res << endl;
  }
   
}
accuracy: 1
time_ms: 20
memory_kb: 6532
final_rank: 11

code_snippet: #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
#include <complex>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-12;

int main(){
  int total_test_cases;
  while(~scanf("%d",&total_test_cases)){
    for(int test_i = 0; test_i < total_test_cases; test_i++){
      int total_staff;
      int speech_duration,prohibited_duration;

      scanf("%d %d %d",&total_staff,
            &speech_duration,&prohibited_duration);
      int customer_x,customer_y;
      scanf("%d %d",&customer_x,&customer_y);
      complex<int> customer(customer_x,customer_y);

      vector<complex<int> > staff;
      for(int staff_i = 0; staff_i < total_staff; staff_i++){
        int x,y;
        scanf("%d %d",&x,&y);
        staff.push_back(complex<int>(x,y));
      }
      
      int latest_speech_finished_time[1001];
      memset(latest_speech_finished_time,-1,sizeof(latest_speech_finished_time));
      queue<int> que;
      for(int staff_i = 0; staff_i < total_staff; staff_i++){
        if((staff[staff_i].real() - customer.real()) * (staff[staff_i].real() - customer.real())
           + (staff[staff_i].imag() - customer.imag()) * (staff[staff_i].imag() - customer.imag()) > 100) continue;
        que.push(staff_i);
        latest_speech_finished_time[staff_i] = speech_duration;
      }
      
      vector<int> edges[1001];
      for(int staff_i = 0; staff_i < total_staff; staff_i++){
        for(int staff_j = 0; staff_j < total_staff; staff_j++){
          if(staff_i == staff_j) continue;
          if((staff[staff_i].real() - staff[staff_j].real()) * (staff[staff_i].real() - staff[staff_j].real())
             + (staff[staff_i].imag() - staff[staff_j].imag()) * (staff[staff_i].imag() - staff[staff_j].imag()) > 2500) continue;
          edges[staff_i].push_back(staff_j);
        }
      }

      bool isok = false;
      for(int round = 0; round < 100000; round++){
        queue<int> next;
        bool visited[1001] = {};
        while(!que.empty()){
          int staff_i = que.front();
          que.pop();
          for(int i = 0; i < edges[staff_i].size(); i++){
            int staff_j = edges[staff_i][i];
            if(latest_speech_finished_time[staff_j] == -1 
               || (latest_speech_finished_time[staff_j] + prohibited_duration
                   < latest_speech_finished_time[staff_i])){
              if(visited[staff_j]) continue;
              next.push(staff_j);
              visited[staff_j] = true;
              latest_speech_finished_time[staff_j]
                = latest_speech_finished_time[staff_i] + speech_duration;
            }
          }
        }
        if(next.empty()){
          isok = true;
          break;
        }
        que = next;
      }
      
      int res = 0;
      for(int i = 0; i < total_staff; i++){
        res = max(res,latest_speech_finished_time[i]);
      }
      if(isok){
        printf("%d\n",res);
      }
      else{
        printf("You're always welcome!\n");
      }
    }
  }
}
accuracy: 1
time_ms: 910
memory_kb: 5264
final_rank: 16

code_snippet: #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
#include <complex>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int main(){
  int total_test_cases;
  while(~scanf("%d",&total_test_cases)){
    for(int test_i = 0; test_i < total_test_cases; test_i++){
      int total_staff;
      int speech_duration,prohibited_duration;

      scanf("%d %d %d",&total_staff,
            &speech_duration,&prohibited_duration);
      double customer_x,customer_y;
      scanf("%lf %lf",&customer_x,&customer_y);
      vector<complex<double> > staff;
      for(int staff_i = 0; staff_i < total_staff; staff_i++){
        double x,y;
        scanf("%lf %lf",&x,&y);
        staff.push_back(complex<double>(x,y));
      }
      
      int latest_speech_finished_time[1001];
      memset(latest_speech_finished_time,-1,sizeof(latest_speech_finished_time));
      queue<int> que;
      for(int staff_i = 0; staff_i < total_staff; staff_i++){
        if(abs(staff[staff_i] - complex<double>(customer_x,customer_y)) > 10.0) continue;
        que.push(staff_i);
        latest_speech_finished_time[staff_i] = speech_duration;
      }
      
      vector<int> edges[1001];
      for(int staff_i = 0; staff_i < total_staff; staff_i++){
        for(int staff_j = 0; staff_j < total_staff; staff_j++){
          if(staff_i == staff_j) continue;
          if(abs(staff[staff_i] - staff[staff_j]) > 50.0) continue;
          edges[staff_i].push_back(staff_j);
        }
      }

      bool isok = false;
      for(int round = 0; round < 100000; round++){
        queue<int> next;
        bool visited[1001] = {};
        while(!que.empty()){
          int staff_i = que.front();
          que.pop();
          for(int i = 0; i < edges[staff_i].size(); i++){
            int staff_j = edges[staff_i][i];
            if(latest_speech_finished_time[staff_j] == -1 
               || (latest_speech_finished_time[staff_j] + prohibited_duration
                   < latest_speech_finished_time[staff_i])){
              if(visited[staff_j]) continue;
              next.push(staff_j);
              visited[staff_j] = true;
              latest_speech_finished_time[staff_j]
                = latest_speech_finished_time[staff_i] + speech_duration;
            }
          }
        }
        if(next.empty()){
          isok = true;
          break;
        }
        que = next;
      }
      
      int res = 0;
      for(int i = 0; i < total_staff; i++){
        res = max(res,latest_speech_finished_time[i]);
      }
      if(isok){
        printf("%d\n",res);
      }
      else{
        printf("You're always welcome!\n");
      }
    }
  }
}
accuracy: 1
time_ms: 1010
memory_kb: 5320
final_rank: 18

code_snippet: #include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 1010
 
struct Point{
  double x,y;
  Point(){}
  Point(double x,double y) : x(x),y(y) {}
};
 
int N,X,Y;
vector<int> G[MAX];
 
double getDist(Point &a,Point &b){
  return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
 
void init(){
  for(int i = 0 ; i < MAX ; i++){
    G[i].clear();
  }  
}
 
void solve(){
  int d[MAX] = {0};
  queue<int> Q; Q.push(0);
  bool can = true;
  
  while(!Q.empty()){
    int v = Q.front(); Q.pop();
    for(int i = 0 ; i < (int)G[v].size() ; i++){
      int to = G[v][i];
      if(d[to] == 0){
        d[to] = d[v] + 1;
        if(v > 0 && X > Y){
          can = false;
          break;
        }
        Q.push(to);
      }
    }
    if(!can){ break; }
  }
  
  if(can){
    cout << *max_element(d+1,d+N+1)*X << endl;
  }else{
    cout << "You're always welcome!" << endl;
  }
}
 
int main(){
  int Tc;
  cin >> Tc;
  while(Tc--){
    init();
    Point sp;
    vector<Point> p;
    cin >> N >> X >> Y;
    cin >> sp.x >> sp.y;
    p.resize(N);
    for(int i = 0 ; i < N ; i++){
      cin >> p[i].x >> p[i].y;
      if(getDist(sp,p[i]) <= 10){
        G[0].push_back(i+1);
      }
    }
    for(int i = 0 ; i < N ; i++){
      for(int j = 0 ; j < N ; j++){
        if(i == j){ continue; }
        if(getDist(p[i],p[j]) <= 50){
          G[i+1].push_back(j+1);
        }
      }
    }
    solve();
  }
  return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 5316
final_rank: 9

code_snippet: #include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 1010
 
struct Point{
  double x,y;
  Point(){}
  Point(double x,double y) : x(x),y(y) {}
};
 
int N,X,Y;
vector<int> G[MAX];
 
double getDist(Point &a,Point &b){
  return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
 
void init(){
  for(int i = 0 ; i < MAX ; i++){
    G[i].clear();
  }  
}
 
void solve(){
  int d[MAX] = {0};
  queue<int> Q; Q.push(0);
  bool can = true;
  
  while(!Q.empty()){
    int v = Q.front(); Q.pop();
    for(int i = 0 ; i < (int)G[v].size() ; i++){
      int to = G[v][i];
      if(d[to] == 0){
        d[to] = d[v] + 1;
        if(v > 0 && X > Y){ can = false; }
        Q.push(to);
      }
    }
  }
  
  if(can){
    cout << *max_element(d+1,d+N+1)*X << endl;
  }else{
    cout << "You're always welcome!" << endl;
  }
}
 
int main(){
  int Tc;
  cin >> Tc;
  while(Tc--){
    init();
    Point sp;
    vector<Point> p;
    cin >> N >> X >> Y;
    cin >> sp.x >> sp.y;
    p.resize(N);
    for(int i = 0 ; i < N ; i++){
      cin >> p[i].x >> p[i].y;
      if(getDist(sp,p[i]) <= 10){
        G[0].push_back(i+1);
      }
    }
    for(int i = 0 ; i < N ; i++){
      for(int j = 0 ; j < N ; j++){
        if(i == j){ continue; }
        if(getDist(p[i],p[j]) <= 50){
          G[i+1].push_back(j+1);
        }
      }
    }
    solve();
  }
  return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 5312
final_rank: 8

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define MAX 1010

struct Point{
  double x,y;
  Point(){}
  Point(double x,double y) : x(x),y(y) {}
};

int N,X,Y;
Point sp;
vector<Point> p;
vector<int> G[MAX];

double getDist(Point &a,Point &b){
  return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}

void init(){
  for(int i = 0 ; i < MAX ; i++){
    G[i].clear();
  }  
}

void solve(){
  int res = 0;
  queue<int> que;
  que.push(0);
  int d[N+1];
  memset(d,0,sizeof(d));
  bool ok=1;
  while(!que.empty()) {
    int x=que.front();que.pop();
    for(int i=0; i<G[x].size(); i++) {
      int y=G[x][i];
      if(d[y]) continue;
      if(x && X>Y) ok=0;
      d[y]=d[x]+1;
      que.push(y);
    }
  }
  for(int i=1; i<=N; i++) res=max(res,d[i]*X);
  if(ok) cout << res << endl;
  else cout << "You're always welcome!" << endl;
}

int main(){
  int Tc;
  cin >> Tc;
  while(Tc--){
    init();
    cin >> N >> X >> Y;
    cin >> sp.x >> sp.y;
    p.resize(N);
    for(int i = 0 ; i < N ; i++){
      cin >> p[i].x >> p[i].y;
      if(getDist(sp,p[i]) <= 10){
	G[0].push_back(i+1);
      }
    }
    for(int i = 0 ; i < N ; i++){
      for(int j = 0 ; j < N ; j++){
	if(i == j){ continue; }
	if(getDist(p[i],p[j]) <= 50){
	  G[i+1].push_back(j+1);
	}
      }
    }
    solve();
  }
  return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 5324
final_rank: 10

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int N,T;

vector<int> G[1111];
bool F[1111][1111];
int X,Y;

int dub(int a){ return a*a; }
int abs( P a, P b ){
  return dub(a.first-b.first)+dub(a.second-b.second);
}

int main(){
  cin >> T;
  while( T-- ){
    for(int i=0;i<N;i++) G[i].clear();
    cin >> N >> X >> Y;
    P s;
    cin >> s.first >> s.second;
    P v[1111];
    for(int i=0;i<N;i++)
      cin>> v[i].first >> v[i].second;    
    queue<int> q;
    int H[1111] = {};
    for(int i=0;i<N;i++){
      if( abs( s, v[i] ) <= 10*10 ) {
        q.push( i );
        H[i] = X;
      }
      for(int j=i+1;j<N;j++){       
        if( abs(v[i],v[j]) <= 50*50 ){
          G[i].push_back( j );
          G[j].push_back( i );
        }
      }
    }
    
    memset(F,0,sizeof(F));
    int res = 0;
    while( !q.empty() ){
      int p = q.front(); q.pop();
      int time = H[p];
      res = max( res, time );
      //  cout<< p << " "<< time << endl;
      for(int i=0;i<(int)G[p].size();i++){
        int to =G[p][i];
        if( H[to] > 0 && H[to] >= time - Y ) continue;
        if( F[i][to] ){
          res = -1; goto end;
        }
        F[i][to] = true;
        q.push( to );
        H[to] = time + X;
      }
    }
  end:;
    if( res == -1 ) cout << "You're always welcome!" << endl;
    else cout << res << endl;
  }
  
}
accuracy: 1
time_ms: 20
memory_kb: 6532
final_rank: 11

code_snippet: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
typedef pair<int, int> PI;
const double EPS = 1e-8;

int N, X, Y;

void input(P &tar){
  int x, y; cin >>x >>y;
  tar.real(x);
  tar.imag(y);
}

int dist2(P &a, P &b){
  return (a.real() - b.real()) * (a.real() - b.real()) + (a.imag() - b.imag()) * (a.imag() - b.imag());
}

int solve(P &c, vector<P> &v){
  priority_queue<PI, vector<PI>, greater<PI> > open;
  vector<int> closed(N, -1);
  REP(i, N) if(dist2(c, v[i]) <= 10 * 10) open.push(PI(0, i));
  int cnt = 0;
  while(!open.empty()){
    ++cnt;
    if(cnt > 1000 * 1000) return -1;
    int t = open.top().first, n = open.top().second; open.pop();
    if(t != 0 && closed[n] != -1 && closed[n] + Y >= t) continue;
    closed[n] = t + X;
    REP(i, N) if(i != n && dist2(v[n], v[i]) <= 50 * 50) open.push(PI(t + X, i));
  }
  int ans = 0;
  REP(i, N) ans = max(ans, closed[i]);
  return ans;
}


int main() {
  int T; cin >>T;
  while(T--){
    cin >>N >>X >>Y;
    P c;
    vector<P> v(N);
    input(c);
    REP(i, N) input(v[i]);
    int ans = solve(c, v);
    if(ans == -1) cout <<"You're always welcome!" <<endl;
    else cout <<ans <<endl;
  }
  return 0;
}
accuracy: 1
time_ms: 510
memory_kb: 9596
final_rank: 20

code_snippet: #include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

constexpr int INF = (1 << 29);

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }

int dist2(int x1, int y1, int x2, int y2) {
	const int diff_x = x1 - x2;
	const int diff_y = y1 - y2;
	return diff_x * diff_x + diff_y * diff_y;
}

string solve() {
	int n, X, Y;
	cin >> n >> X >> Y;

	int nx, ny;
	cin >> nx >> ny;

	vector<int> xs(n), ys(n), label(n, INF);
	queue<int> que;
	vector<vector<int>> es(n);

	for(int i = 0; i < n; ++i) {
		cin >> xs[i] >> ys[i];
		if(dist2(nx, ny, xs[i], ys[i]) <= 10 * 10) {
			que.push(i);
			label[i] = 1;
		}

		for(int j = 0; j < i; ++j) {
			if(dist2(xs[i], ys[i], xs[j], ys[j]) <= 50 * 50) {
				es[i].emplace_back(j);
				es[j].emplace_back(i);
			}
		}
	}

	if(X > Y) {
		if(que.empty()) return "0";
		while(!que.empty()) {
			const int v = que.front();
			for(const auto &to : es[v]) {
				if(label[to] == INF) return "You're always welcome!";
			}
			que.pop();
		}
		return to_string(X);
	}

	int mx = 0;
	while(!que.empty()) {
		const int v = que.front();
		que.pop();
		chmax(mx, label[v]);

		for(const auto &to : es[v]) {
			if(label[to] == INF) {
				label[to] = label[v] + 1;
				que.push(to);
			}
		}
	}
	return to_string(mx * X);
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int t;
	cin >> t;
	while(t--) cout << solve() << endl;

	return EXIT_SUCCESS;
}
accuracy: 1
time_ms: 20
memory_kb: 5240
final_rank: 1

code_snippet: #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<climits>
#include<deque>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX 1010
#define pow2(a) ((a)*(a))

using namespace std;

struct Point{
  int x,y;
  Point(int x=IINF,int y=IINF):x(x),y(y){}
};

struct Data{
  int cur,cost;
  Data(int cur=IINF,int cost=IINF):cur(cur),cost(cost){}
};

inline double dist(Point a,Point b){
  return sqrt(pow2(abs(a.x-b.x))+pow2(abs(a.y-b.y)));
}

int N,X,Y;
vector<int> G[MAX];

int main()
{
  int T;
  cin >> T;
  while(T--){
    cin >> N >> X >> Y;

    rep(i,N)G[i].clear();

    deque<Data> deq;
    bool used[N+1];
    Point ps[N+1];
    rep(i,N+1){
      used[i] = false;
      cin >> ps[i].x >> ps[i].y;
    }

    REP(i,1,N+1){
      if(dist(ps[0],ps[i]) <= 10.0){
	deq.push_back(Data(i-1,1));
	used[i-1] = true;
      }
      REP(j,i+1,N+1){
	if(dist(ps[i],ps[j]) <= 50.0){
	  G[i-1].push_back(j-1);
	  G[j-1].push_back(i-1);
	}
      }
    }

    if(deq.empty()){
      cout << 0 << endl;
      continue;
    }

    int maxcost = 1;
    while(!deq.empty()){
      Data data = deq.front(); deq.pop_front();

      for(int next : G[data.cur]){
	if(used[next])continue;
	used[next] = true;
	maxcost = max(maxcost,data.cost+1);
	deq.push_back(Data(next,data.cost+1));
      }

    }

    if( X > Y && maxcost == 1){
      cout << X << endl;
      continue;
    }

    if( X > Y ){
      cout << "You're always welcome!" << endl;
    } else {
      cout << X*maxcost << endl;
    }

  }
  return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 5316
final_rank: 6

code_snippet: #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<cassert>
#include<sstream>
#include<complex>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<ctime>
#include<cctype>
#include<unordered_map>
#include<unordered_set>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define all(n) (n).begin(),(n).end()
#define MAX 1010
#define pow2(a) ((a)*(a))

using namespace std;

struct Point{
  int x,y;
  Point(int x=IINF,int y=IINF):x(x),y(y){}
};

struct Data{
  int cur,cost;
  Data(int cur=IINF,int cost=IINF):cur(cur),cost(cost){}
};

inline double dist(Point a,Point b){
  return sqrt(pow2(abs(a.x-b.x))+pow2(abs(a.y-b.y)));
}

int N,X,Y;
vector<int> G[MAX];

int main()
{
  int T;
  cin >> T;
  while(T--){
    cin >> N >> X >> Y;

    rep(i,N)G[i].clear();

    deque<Data> deq;
    bool used[N+1];
    Point ps[N+1];
    rep(i,N+1){
      used[i] = false;
      cin >> ps[i].x >> ps[i].y;
    }

    REP(i,1,N+1){
      if(dist(ps[0],ps[i]) <= 10.0){
	deq.push_back(Data(i-1,1));
	used[i-1] = true;
      }
      REP(j,i+1,N+1){
	if(dist(ps[i],ps[j]) <= 50.0){
	  G[i-1].push_back(j-1);
	  G[j-1].push_back(i-1);
	}
      }
    }

    if(deq.empty()){
      cout << 0 << endl;
      continue;
    }
    /*
    rep(sp,N){
      cout << "from " << sp << " : ";
      for(int next : G[sp]){
	cout << next << " ";
      }
      cout << endl;
    }
    cout << endl;
    */
    int maxcost = 1;
    while(!deq.empty()){
      Data data = deq.front(); deq.pop_front();

      for(int next : G[data.cur]){
	if(used[next])continue;
	used[next] = true;
	maxcost = max(maxcost,data.cost+1);
	deq.push_back(Data(next,data.cost+1));
      }

    }

    if( X > Y && maxcost == 1){
      cout << X << endl;
      continue;
    }

    if( X > Y ){
      cout << "You're always welcome!" << endl;
    } else {
      cout << X*maxcost << endl;
    }

  }
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 5316
final_rank: 4

code_snippet: #include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
#define reps(i,j,n) for(int i = j ; i < n ; ++i)
#define rep(i, n) reps(i,0,n)
#define fr first
#define sc second
#define SQR(x) ((x)*(x))
#define INF (1 << 28)
typedef pair< int , int > Pt;

int main(){
  int Q;
  int N,X,Y;
  Pt Natume;
  int x[1000],y[1000];
  vector< vector<int> > set;

  cin >> Q;
  while(Q--){
    //Input
    cin >> N >> X >> Y;
    cin >> Natume.sc >> Natume.fr;
    set.resize(N);
    rep(i,N) cin >> x[i] >> y[i];
    rep(i,N) rep(j,N){
      if(SQR(x[i] - x[j]) + SQR(y[i] - y[j]) <= 2500){
        set[i].push_back(j);
      }
    }
    //end

    queue< Pt > que;
    int Say[1000],cnt = 0,flg = 1,END = 1000,ans = 0;
    fill_n(Say,1000,-INF);
    rep(i,N){
      if(SQR(x[i] - Natume.sc) + SQR(y[i] - Natume.fr) <= 100){
        Say[i] = X;
        que.push(Pt(X,i));
      }
    }
    while(!que.empty()){
      Pt p = que.front(); que.pop();
      int now = p.sc , time = p.fr;
      cnt++;
      if(cnt > END){ flg--; break; }
      rep(i,set[now].size()){
        int e = set[now][i];
        if(time - Say[e] > Y){
          Say[e] = X + time;
          que.push(Pt(Say[e],e));
        }
      }
    }
    rep(i,N) ans = max(ans,Say[i]);

    //Output
    if(!flg) cout << "You're always welcome!" << endl;
    else cout << ans << endl;
    //end

    set.clear();
    }
}
accuracy: 1
time_ms: 30
memory_kb: 5228
final_rank: 2

code_snippet: #include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
#define reps(i,j,n) for(int i = j ; i < n ; ++i)
#define rep(i, n) reps(i,0,n)
#define fr first
#define sc second
#define SQR(x) ((x)*(x))
#define INF (1 << 28)
typedef pair< int , int > Pt;

int main(){
  int Q;
  int N,X,Y;
  Pt Natume;
  int x[1000],y[1000];
  vector< vector<int> > set;

  cin >> Q;
  while(Q--){
    //Input
    cin >> N >> X >> Y;
    cin >> Natume.sc >> Natume.fr;
    set.resize(N);
    rep(i,N) cin >> x[i] >> y[i];
    rep(i,N) rep(j,N){
      if(SQR(x[i] - x[j]) + SQR(y[i] - y[j]) <= 2500){
        set[i].push_back(j);
      }
    }
    //end

    queue< Pt > que;
    int Say[1000],cnt = 0,flg = 1,END = 1500,ans = 0;
    fill_n(Say,1000,-INF);
    rep(i,N){
      if(SQR(x[i] - Natume.sc) + SQR(y[i] - Natume.fr) <= 100){
        Say[i] = X;
        que.push(Pt(X,i));
      }
    }
    while(!que.empty()){
      Pt p = que.front(); que.pop();
      int now = p.sc , time = p.fr;
      cnt++;
      if(cnt > END){ flg--; break; }
      rep(i,set[now].size()){
        int e = set[now][i];
        if(time - Say[e] > Y){
          Say[e] = X + time;
          que.push(Pt(Say[e],e));
        }
      }
    }
    rep(i,N) ans = max(ans,Say[i]);

    //Output
    if(!flg) cout << "You're always welcome!" << endl;
    else cout << ans << endl;
    //end

    set.clear();
    }
}
accuracy: 1
time_ms: 30
memory_kb: 5228
final_rank: 2

code_snippet: #include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
#define reps(i,j,n) for(int i = j ; i < n ; ++i)
#define rep(i, n) reps(i,0,n)
#define fr first
#define sc second
#define SQR(x) ((x)*(x))
#define INF (1 << 28)
typedef pair< int , int > Pt;

int main(){
  int Q;
  int N,X,Y;
  Pt Natume;
  int x[1000],y[1000];
  vector< vector<int> > set;

  cin >> Q;
  while(Q--){
    //Input
    cin >> N >> X >> Y;
    cin >> Natume.sc >> Natume.fr;
    set.resize(N);
    rep(i,N) cin >> x[i] >> y[i];
    rep(i,N) rep(j,N){
      if(SQR(x[i] - x[j]) + SQR(y[i] - y[j]) <= 2500){
        set[i].push_back(j);
      }
    }
    //end

    queue< Pt > que;
    int Say[1000],cnt = 0,flg = 1,END = 2*N*N,ans = 0;
    fill_n(Say,1000,-INF);
    rep(i,N){
      if(SQR(x[i] - Natume.sc) + SQR(y[i] - Natume.fr) <= 100){
        Say[i] = X;
        que.push(Pt(X,i));
      }
    }
    while(!que.empty()){
      Pt p = que.front(); que.pop();
      int now = p.sc , time = p.fr;
      cnt++;
      if(cnt > END){ flg--; break; }
      rep(i,set[now].size()){
        int e = set[now][i];
        if(time - Say[e] > Y){
          Say[e] = X + time;
          que.push(Pt(Say[e],e));
        }
      }
    }
    rep(i,N) ans = max(ans,Say[i]);

    //Output
    if(!flg) cout << "You're always welcome!" << endl;
    else cout << ans << endl;
    //end

    set.clear();
    }
}
accuracy: 1
time_ms: 50
memory_kb: 5228
final_rank: 7