Submission #315708

#TimeUsernameProblemLanguageResultExecution timeMemory
315708ahmetPastiri (COI20_pastiri)C++14
8 / 100
406 ms67684 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...