Submission #342477

# Submission time Handle Problem Language Result Execution time Memory
342477 2021-01-02T08:11:43 Z urd05 Spring cleaning (CEOI20_cleaning) C++14
9 / 100
53 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);
        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)-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 Correct 17 ms 1000 KB Output is correct
2 Correct 17 ms 1000 KB Output is correct
3 Correct 25 ms 268 KB Output is correct
4 Correct 53 ms 1000 KB Output is correct
5 Correct 21 ms 364 KB Output is correct
# 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 26 ms 364 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 -