Submission #845389

# Submission time Handle Problem Language Result Execution time Memory
845389 2023-09-06T13:26:37 Z vjudge1 Birmingham (COCI20_birmingham) C++
70 / 70
500 ms 11216 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long a,b,c,d,e,f,gun,ay,yil,es,p;
	vector < vector <long long> > adj;
	queue <long long> que;
	vector <long long> ana;
	long long uza[100005];
	memset(uza,-1,sizeof(uza));
	cin>>a>>b>>c>>d;
	for(long long i=0;a>=i;i++){
		adj.push_back(ana);
	}
	for(long long i=0;c>i;i++){
		cin>>f;
		ana.push_back(f);
	}
	for(long long i=0;b>i;i++){
		cin>>f>>p;
		adj[f].push_back(p);
		adj[p].push_back(f);
	}
	for(long long i=0;c>i;i++){
		long long pivot = ana[i];
		int vis[100005];
		memset(vis,0,sizeof(vis));
		uza[pivot] = 0;
		que.push(pivot);
		while(que.size()){
			pivot = que.front();
			que.pop();
			if(vis[pivot] == 0){
			vis[pivot] = 1;
			for(long long j=0;adj[pivot].size()>j;j++){
				if(uza[adj[pivot][j]] == -1){
					uza[adj[pivot][j]] = uza[pivot] + 1;
					if(vis[adj[pivot][j]] == 0)
					que.push(adj[pivot][j]);
				}
				else{
					if(uza[adj[pivot][j]] > uza[pivot] + 1){
						uza[adj[pivot][j]] = uza[pivot] + 1;
						if(vis[adj[pivot][j]] == 0)
						que.push(adj[pivot][j]);
					}
				}
			}
			}
		}
	}
	for(long long i=1;a>=i;i++){
		long long pork=1;
		//cout<<uza[i]<<" ";
		if(uza[i] == 0){
			cout<<0<<" ";
		}
		else{
			long long h=(pork * (pork+1));
			h/=2;
			h*=d;
			while(h < uza[i]){
				pork++;
				h=(pork * (pork+1));
				h/=2;
				h*=d;
			}
			cout<<pork<<" ";
		}

	}


	
}

Compilation message

birmingham.cpp: In function 'int main()':
birmingham.cpp:36:39: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   36 |    for(long long j=0;adj[pivot].size()>j;j++){
      |                      ~~~~~~~~~~~~~~~~~^~
birmingham.cpp:6:20: warning: unused variable 'e' [-Wunused-variable]
    6 |  long long a,b,c,d,e,f,gun,ay,yil,es,p;
      |                    ^
birmingham.cpp:6:24: warning: unused variable 'gun' [-Wunused-variable]
    6 |  long long a,b,c,d,e,f,gun,ay,yil,es,p;
      |                        ^~~
birmingham.cpp:6:28: warning: unused variable 'ay' [-Wunused-variable]
    6 |  long long a,b,c,d,e,f,gun,ay,yil,es,p;
      |                            ^~
birmingham.cpp:6:31: warning: unused variable 'yil' [-Wunused-variable]
    6 |  long long a,b,c,d,e,f,gun,ay,yil,es,p;
      |                               ^~~
birmingham.cpp:6:35: warning: unused variable 'es' [-Wunused-variable]
    6 |  long long a,b,c,d,e,f,gun,ay,yil,es,p;
      |                                   ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 2 ms 1880 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1624 KB Output is correct
3 Correct 1 ms 1624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 2 ms 1624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1624 KB Output is correct
3 Correct 1 ms 1624 KB Output is correct
4 Correct 1 ms 1624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1624 KB Output is correct
3 Correct 1 ms 1624 KB Output is correct
4 Correct 1 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1772 KB Output is correct
2 Correct 1 ms 1624 KB Output is correct
3 Correct 1 ms 1624 KB Output is correct
4 Correct 1 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 10176 KB Output is correct
2 Correct 56 ms 10688 KB Output is correct
3 Correct 322 ms 10940 KB Output is correct
4 Correct 51 ms 9620 KB Output is correct
5 Correct 51 ms 9912 KB Output is correct
6 Correct 471 ms 11072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 10684 KB Output is correct
2 Correct 56 ms 10428 KB Output is correct
3 Correct 269 ms 10728 KB Output is correct
4 Correct 62 ms 10732 KB Output is correct
5 Correct 58 ms 10940 KB Output is correct
6 Correct 500 ms 10168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 10428 KB Output is correct
2 Correct 59 ms 10688 KB Output is correct
3 Correct 320 ms 10940 KB Output is correct
4 Correct 62 ms 10684 KB Output is correct
5 Correct 60 ms 9924 KB Output is correct
6 Correct 455 ms 10568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 9792 KB Output is correct
2 Correct 57 ms 10320 KB Output is correct
3 Correct 236 ms 11216 KB Output is correct
4 Correct 58 ms 10172 KB Output is correct
5 Correct 48 ms 9668 KB Output is correct
6 Correct 451 ms 10172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 10432 KB Output is correct
2 Correct 59 ms 10336 KB Output is correct
3 Correct 218 ms 10176 KB Output is correct
4 Correct 59 ms 9976 KB Output is correct
5 Correct 56 ms 10172 KB Output is correct
6 Correct 451 ms 10172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 9920 KB Output is correct
2 Correct 67 ms 10180 KB Output is correct
3 Correct 324 ms 10228 KB Output is correct
4 Correct 61 ms 10360 KB Output is correct
5 Correct 51 ms 10432 KB Output is correct
6 Correct 474 ms 10296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 10228 KB Output is correct
2 Correct 51 ms 9668 KB Output is correct
3 Correct 258 ms 10944 KB Output is correct
4 Correct 53 ms 9916 KB Output is correct
5 Correct 53 ms 10668 KB Output is correct
6 Correct 456 ms 10880 KB Output is correct