Submission #16267697


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
using um = unordered_map<int, long long>;
#define each(i, a) for (auto &&i : (a))

int main() {
  int N, A;
  cin >> N >> A;
  vector<int> x(N);
  each(i, x) cin >> i;
  each(i, x) i -= A;
  function<um(int, int)> div_con = [&](int l, int r) {
    um ret;
    if (r - l == 1)
      ret[x[l]]++;
    else {
      int m = (l + r) / 2;
      um lm = div_con(l, m), rm = div_con(m, r);
      each(p, lm) ret[p.first] += p.second;
      each(p, rm) ret[p.first] += p.second;
      each(p, lm) each(q, rm) ret[p.first + q.first] += p.second * q.second;
    }
    return ret;
  };
  cout << div_con(0, N)[0] << endl;
}

Submission Info

Submission Time
Task C - Tak and Cards
User dnek
Language C++ (GCC 9.2.1)
Score 300
Code Size 657 Byte
Status
Exec Time 8 ms
Memory 3628 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 100 / 100
Status
× 4
× 12
× 24
Set Name Test Cases
Sample example_01.txt, example_02.txt, example_03.txt, example_04.txt
Subtask1 example_01.txt, example_02.txt, example_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt
All example_01.txt, example_02.txt, example_03.txt, example_04.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt
Case Name Status Exec Time Memory
example_01.txt 7 ms 3452 KB
example_02.txt 2 ms 3432 KB
example_03.txt 2 ms 3512 KB
example_04.txt 2 ms 3576 KB
subtask1_01.txt 2 ms 3588 KB
subtask1_02.txt 2 ms 3524 KB
subtask1_03.txt 3 ms 3376 KB
subtask1_04.txt 2 ms 3576 KB
subtask1_05.txt 3 ms 3436 KB
subtask1_06.txt 2 ms 3572 KB
subtask1_07.txt 2 ms 3364 KB
subtask1_08.txt 2 ms 3584 KB
subtask1_09.txt 3 ms 3472 KB
subtask2_01.txt 7 ms 3504 KB
subtask2_02.txt 8 ms 3588 KB
subtask2_03.txt 8 ms 3620 KB
subtask2_04.txt 2 ms 3572 KB
subtask2_05.txt 2 ms 3508 KB
subtask2_06.txt 2 ms 3396 KB
subtask2_07.txt 3 ms 3560 KB
subtask2_08.txt 7 ms 3628 KB
subtask2_09.txt 6 ms 3580 KB
subtask2_10.txt 7 ms 3532 KB
subtask2_11.txt 8 ms 3516 KB