Submission #1007209


Source Code Expand

#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int mod = 1e9 + 7;
const int MAX = 5050;

inline int add(int a, int b) {
  return a+b >= mod ? a+b-mod : a+b;
}

inline int sub(int a, int b) {
  return a >= b ? a-b : a-b+mod;
}

inline int mul(int a, int b) {
  return llint(a)*b % mod;
}

int c[MAX][MAX];
int g[MAX][MAX];

int f(int A, int B, int C) {
  if (B % 2) return 0;

  int kb = B / 2;
  int ans = 0;
  REP(ka, A + 1) {
    int kc = A - ka;
    for (int kd = 0; kc + kd*3 <= C; ++kd) {
      int ways = 1;
      ways = mul(ways, c[ka+kb+kc+kd][ka]);
      ways = mul(ways, c[kb+kc+kd][kb]);
      ways = mul(ways, c[kc+kd][kc]);
      ways = mul(ways, g[kb][C-kc-kd*3]);
      ans = add(ans, ways);
    }
  }
  return ans;
}

int main(void) {
  REP(i, MAX) {
    c[i][0] = 1;
    FOR(j, 1, i+1)
      c[i][j] = add(c[i-1][j], c[i-1][j-1]);
  }

  REP(i, MAX) {
    REP(j, MAX) {
      if (j == 0) { g[i][j] = 1; continue; }
      if (i == 0) continue;
      g[i][j] = add(g[i][j-1], g[i-1][j]);
    }
  }
  
  int N, A, B, C;
  scanf("%d %d %d %d", &N, &A, &B, &C);
  printf("%d\n", f(A, B, C));
  return 0;
}

Submission Info

Submission Time
Task J - 123 Pairs
User ikatanic
Language C++14 (GCC 5.4.1)
Score 1500
Code Size 1433 Byte
Status AC
Exec Time 305 ms
Memory 167808 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:68:39: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d %d", &N, &A, &B, &C);
                                       ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1500 / 1500
Status
AC × 2
AC × 52
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, 046.txt, 047.txt, 048.txt, 049.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 286 ms 167808 KB
001.txt AC 270 ms 167808 KB
002.txt AC 271 ms 167808 KB
003.txt AC 271 ms 167808 KB
004.txt AC 271 ms 167808 KB
005.txt AC 271 ms 167808 KB
006.txt AC 272 ms 167808 KB
007.txt AC 271 ms 167808 KB
008.txt AC 270 ms 167808 KB
009.txt AC 271 ms 167808 KB
010.txt AC 271 ms 167808 KB
011.txt AC 270 ms 167808 KB
012.txt AC 271 ms 167808 KB
013.txt AC 271 ms 167808 KB
014.txt AC 270 ms 167808 KB
015.txt AC 299 ms 167808 KB
016.txt AC 272 ms 167808 KB
017.txt AC 277 ms 167808 KB
018.txt AC 273 ms 167808 KB
019.txt AC 278 ms 167808 KB
020.txt AC 273 ms 167808 KB
021.txt AC 295 ms 167808 KB
022.txt AC 275 ms 167808 KB
023.txt AC 276 ms 167808 KB
024.txt AC 295 ms 167808 KB
025.txt AC 275 ms 167808 KB
026.txt AC 283 ms 167808 KB
027.txt AC 291 ms 167808 KB
028.txt AC 277 ms 167808 KB
029.txt AC 281 ms 167808 KB
030.txt AC 291 ms 167808 KB
031.txt AC 296 ms 167808 KB
032.txt AC 273 ms 167808 KB
033.txt AC 270 ms 167808 KB
034.txt AC 277 ms 167808 KB
035.txt AC 280 ms 167808 KB
036.txt AC 272 ms 167808 KB
037.txt AC 271 ms 167808 KB
038.txt AC 305 ms 167808 KB
039.txt AC 270 ms 167808 KB
040.txt AC 271 ms 167808 KB
041.txt AC 276 ms 167808 KB
042.txt AC 270 ms 167808 KB
043.txt AC 270 ms 167808 KB
044.txt AC 270 ms 167808 KB
045.txt AC 281 ms 167808 KB
046.txt AC 271 ms 167808 KB
047.txt AC 272 ms 167808 KB
048.txt AC 270 ms 167808 KB
049.txt AC 270 ms 167808 KB
example0.txt AC 271 ms 167808 KB
example1.txt AC 271 ms 167808 KB