Submission #1003941

# Submission time Handle Problem Language Result Execution time Memory
1003941 2024-06-20T20:34:06 Z vjudge1 Pastiri (COI20_pastiri) C++17
8 / 100
260 ms 34248 KB
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 500010;
vector <int> v[MAXN];
int ovelha[MAXN], divi[MAXN];

int main(){
	int n, k;
	cin >> n >> k;
	for(int i=1; i<n; i++){
		int a, b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}

	for(int i=0; i<k; i++){
		int a;
		cin >> a;
		ovelha[i] = a;
	}

	sort(ovelha, ovelha+k);

	int resp = 0;
	vector <int> pastor;
	for(int i=0; i<k-1; i++){
		if(divi[i]==1) continue;
		resp++;
		if((ovelha[i+1] - ovelha[i])%2 == 0){
			divi[i+1] = 1;
			pastor.push_back((ovelha[i+1] - ovelha[i])/2 + ovelha[i]);
		}
		else{
			pastor.push_back(ovelha[i]);
		}
	}
	if(divi[k-1]==0){
		resp++;
		pastor.push_back(ovelha[k-1]);
	}
	cout << resp << endl;

	for(int i=0; i<pastor.size(); i++) cout << pastor[i] << " ";
}

Compilation message

pastiri.cpp: In function 'int main()':
pastiri.cpp:45:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |  for(int i=0; i<pastor.size(); i++) cout << pastor[i] << " ";
      |               ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 170 ms 31344 KB Output is correct
2 Correct 185 ms 31316 KB Output is correct
3 Correct 189 ms 31316 KB Output is correct
4 Correct 260 ms 34248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 15964 KB Sheep 3030 not protected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 15964 KB Sheep 128 not protected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 260 ms 31616 KB Sheep 54 not protected
2 Halted 0 ms 0 KB -