Submission #1003941

#TimeUsernameProblemLanguageResultExecution timeMemory
1003941vjudge1Pastiri (COI20_pastiri)C++17
8 / 100
260 ms34248 KiB
#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 (stderr)

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