Submission #808731
Source Code Expand
#include <iostream>
#include <memory>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <array>
#include <sstream>
using namespace std;
uint64_t perm(int n, int m);
uint64_t fact(int x);
int main(int argc, const char * argv[]) {
int N;
vector<pair<int, int>> sks;
uint64_t sum = 0;
cin >> N;
for (int i = 0; i < N; i++) {
string t1, t2;
cin >> t1 >> t2;
sks.push_back(make_pair(atoi(t1.c_str()), atoi(t2.c_str())));
}
for (int i = 0; i < N; i++) {
for (int j = i + 1; j < N; j++) {
int meat = sks[i].first + sks[j].first;
int veg = sks[i].second + sks[j].second;
int u = meat + veg;
int d = max(meat, veg);
sum += perm(u, u - d) / fact(min(meat, veg));
}
}
cout << sum % (1000000007) << endl;
return 0;
}
uint64_t perm(int n, int m) {
uint64_t v = 1;
for (uint64_t i = 0; i < m; i++) v *= (n - i);
return v;
}
uint64_t fact(int x) {
static map<int, uint64_t> memo;
if (memo.find(x) != memo.end()) return memo[x];
uint64_t v = 1;
for (uint64_t i = 1; i <= x; i++) v *= i;
memo[x] = v;
return v;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - BBQ Hard |
| User | tkhp |
| Language | C++14 (Clang 3.8.0) |
| Score | 0 |
| Code Size | 1318 Byte |
| Status | TLE |
| Exec Time | 2105 ms |
| Memory | 2420 KiB |
Judge Result
| Set Name | Sample | All | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 1400 | ||||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample-01.txt |
| All | sample-01.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01-01.txt | RE | 197 ms | 256 KiB |
| 01-02.txt | RE | 198 ms | 256 KiB |
| 01-03.txt | RE | 341 ms | 1400 KiB |
| 01-04.txt | RE | 490 ms | 2420 KiB |
| 01-05.txt | RE | 498 ms | 2420 KiB |
| 01-06.txt | RE | 508 ms | 2420 KiB |
| 01-07.txt | AC | 4 ms | 256 KiB |
| 01-08.txt | TLE | 2105 ms | 2420 KiB |
| 01-09.txt | RE | 505 ms | 2420 KiB |
| 01-10.txt | RE | 508 ms | 2420 KiB |
| 01-11.txt | RE | 502 ms | 2420 KiB |
| 01-12.txt | RE | 503 ms | 2420 KiB |
| 01-13.txt | RE | 501 ms | 2420 KiB |
| 01-14.txt | RE | 503 ms | 2420 KiB |
| sample-01.txt | AC | 4 ms | 256 KiB |