Submission #342476

# Submission time Handle Problem Language Result Execution time Memory
342476 2021-01-02T08:09:42 Z urd05 Spring cleaning (CEOI20_cleaning) C++14
0 / 100
23 ms 1000 KB
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int n,q;
    scanf("%d %d",&n,&q);
    for(int i=1;i<n;i++) {
        int u,v;
        scanf("%d %d",&u,&v);
    }
    vector<int> v;
    int en=n-1;
    int k;
    scanf("%d",&k);
    int l=2;
    for(int i=0;i<k;i++) {
        int x;
        scanf("%d",&x);
        if (x==n-1&&en==n-1) {
            en++;
        }
        else {
            v.push_back(x);
            l++;
        }
    }
    v.push_back(0);
    v.push_back(en);
    sort(v.begin(),v.end());
    if (l%2==1) {
        printf("-1");
        return 0;
    }
    int ret=n-1+k;
    for(int i=1;i<en;i++) {
        int sum=lower_bound(v.begin(),v.end(),i-1)-v.begin();
        if (sum%2==0) {
            ret++;
        }
    }
    printf("%d",ret);
}

Compilation message

cleaning.cpp: In function 'int main()':
cleaning.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    6 |     scanf("%d %d",&n,&q);
      |     ~~~~~^~~~~~~~~~~~~~~
cleaning.cpp:9:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |         scanf("%d %d",&u,&v);
      |         ~~~~~^~~~~~~~~~~~~~~
cleaning.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |     scanf("%d",&k);
      |     ~~~~~^~~~~~~~~
cleaning.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |         scanf("%d",&x);
      |         ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 1000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 1000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -