Submission #315708

# Submission time Handle Problem Language Result Execution time Memory
315708 2020-10-23T18:45:12 Z ahmet Pastiri (COI20_pastiri) C++14
8 / 100
406 ms 67684 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
const int mx=2e6+5;
int n,k;
vector <int> v[mx];
vector <int> a;
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	/*freopen(".in", "r", stdin);
	freopen(".out", "w", stdout); 
    */
	cin >> n >> k;
	rep(i,n-1){
		int x,y;cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	rep(i,k){
		int x;cin >> x;
		a.pb(x);
	}
	sort(a.begin(),a.end());
	vector <int> ans;
	for(int i=0;i<a.size();++i){
		if(i==a.size()-1){
			ans.pb(a[i]);
			continue;
		}
		int d=a[i+1]-a[i];
		if(d%2==0){
			ans.pb(a[i]+d/2);
			++i;
			continue;
		}
		ans.pb(a[i]);
	}
	cout << ans.size() << endl;
	for(int i=0;i<ans.size();++i){
		cout << ans[i] << " ";
	}





	
}
	

Compilation message

pastiri.cpp: In function 'int main()':
pastiri.cpp:4:32: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
      |                                ^
pastiri.cpp:21:2: note: in expansion of macro 'rep'
   21 |  rep(i,n-1){
      |  ^~~
pastiri.cpp:4:32: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
      |                                ^
pastiri.cpp:26:2: note: in expansion of macro 'rep'
   26 |  rep(i,k){
      |  ^~~
pastiri.cpp:32:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for(int i=0;i<a.size();++i){
      |              ~^~~~~~~~~
pastiri.cpp:33:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   if(i==a.size()-1){
      |      ~^~~~~~~~~~~~
pastiri.cpp:46:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |  for(int i=0;i<ans.size();++i){
      |              ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 183 ms 63096 KB Output is correct
2 Correct 176 ms 62968 KB Output is correct
3 Correct 177 ms 62968 KB Output is correct
4 Correct 257 ms 67684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 47480 KB Sheep 3030 not protected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 47412 KB Sheep 128 not protected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 406 ms 63176 KB Sheep 54 not protected
2 Halted 0 ms 0 KB -