QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#752371#8134. LCA Countingucup-team3646WA 0ms3864kbC++201.2kb2024-11-16 01:22:102024-11-16 01:22:11

Judging History

你现在查看的是最新测评结果

  • [2024-11-16 01:22:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3864kb
  • [2024-11-16 01:22:10]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep2(i, l, r) for (ll i = l; i < r; i++)

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

/* ---- */
#define all(A) A.begin(), A.end()
#define elif else if
using pii = pair<ll, ll>;

bool chmin(auto &a, const auto &b) { return a > b ? a = b, 1 : 0; }
bool chmax(auto &a, const auto &b) { return a < b ? a = b, 1 : 0; }

struct IOSetup {
  IOSetup() {
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
} iosetup;

template <class T>
void print(vector<T> a) {
  for (auto x : a) cerr << x << ' ';
  cerr << endl;
}

void print(auto x) { cerr << x << endl; }

template <class Head, class... Tail>
void print(Head &&head, Tail &&...tail) {
  cerr << head << ' ';
  print(forward<Tail>(tail)...);
}

int main(){
  int n;
  cin>>n;
  vi deg(n,0);
  rep(i,n-1){
    int p;
    cin>>p;
    p--;
    deg[p]++;
  }
  int l=0;
  rep(i,n)if(deg[i]==0)l++;
  int rem=0;
  rep(i,n){
    if(deg[i]>=2)rem++;
  }
  int ans=1;
  rep(i,l){
    cout<<ans<<" \n"[i+1==l];
    if(rem>0){
      rem--;
      ans++;
    }
    ans++;
  }
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3616kb

input:

7
1 1 2 4 2 2

output:

1 3 5 6

result:

ok 4 number(s): "1 3 5 6"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

10
1 1 2 2 1 1 1 2 4

output:

1 3 5 6 7 8 9

result:

ok 7 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

10
1 2 2 4 5 6 1 2 4

output:

1 3 5 7 8

result:

ok 5 number(s): "1 3 5 7 8"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

10
1 2 3 3 3 5 6 4 9

output:

1 3 4

result:

ok 3 number(s): "1 3 4"

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3576kb

input:

1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 4 1 2 2 1 1 1 1 2 1 1 1 1 2 2 1 1 1 1 1 6 3 1 1 1 2 2 1 1 2 1 2 1 3 1 2 1 1 2 1 1 1 1 1 1 1 4 1 5 1 1 1 1 1 2 1 1 2 1 2 1 2 5 3 1 3 1 1 2 1 2 1 1 3 2 1 6 2 1 2 5 1 1 1 3 2 1 2 1 1 1 1 1...

output:

1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 12...

result:

wrong answer 5th numbers differ - expected: '8', found: '9'