Submission #1131266
Source Code Expand
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define li long long #define itn int using namespace std; inline int nxt(){ int n; scanf("%d", &n); return n; } ostream& operator <<(ostream& ostr, const vector<int>& a) { ostr << "("; for (size_t i = 0; i < a.size(); ++i) { if (i) { ostr << ", "; } ostr << a[i]; } ostr << ")"; return ostr; } int main(){ int n = nxt(); vector<int> a(n); for (int i = 0; i < n; ++i) { a[i] = nxt(); } vector<int> dp(n); dp[0] = a[0]; for (int i = 1; i < n; ++i) { if (a[i] == a[i - 1] + 1) { if (dp[i - 1] == a[i - 1] - 2 * (i - 1)) { dp[i] = dp[i - 1] - 1; } else { dp[i] = dp[i - 1]; } } else { dp[i] = dp[i - 1]; } } vector<int> place(n); for (int i = 1; i < n; ++i) { if (dp[i - 1] > 0) { place[i] = 0; } else { place[i] = 1 + (-dp[i - 1]) / 2; } } // cerr << dp << "\n"; const int mod = 1000000007; long long ans = 1; vector<int> cnt(1, 0); for (int i = 0; i < n; ++i) { while (place[i] >= cnt.size()) { cnt.push_back(cnt.back()); } cnt.back() += 1; } while (cnt.size() < n) { cnt.push_back(cnt.back()); } for (int i = 0; i < n; ++i) { ans = ans * (cnt[i] - i) % mod; } cout << ans << "\n"; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Robot Racing |
User | Golovanov399 |
Language | C++14 (GCC 5.4.1) |
Score | 900 |
Code Size | 1382 Byte |
Status | AC |
Exec Time | 15 ms |
Memory | 2044 KB |
Compile Error
./Main.cpp: In function ‘int nxt()’: ./Main.cpp:12:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^
Judge Result
Set Name | Sample | Subtask | All | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | 400 / 400 | ||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
Subtask | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt, 2_04.txt, 2_05.txt, 2_06.txt, 2_07.txt, 2_08.txt, 2_09.txt, 2_10.txt, 2_11.txt, 2_12.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 1 ms | 256 KB |
0_01.txt | AC | 1 ms | 256 KB |
0_02.txt | AC | 1 ms | 256 KB |
0_03.txt | AC | 1 ms | 256 KB |
1_00.txt | AC | 1 ms | 256 KB |
1_01.txt | AC | 1 ms | 256 KB |
1_02.txt | AC | 1 ms | 256 KB |
1_03.txt | AC | 1 ms | 256 KB |
1_04.txt | AC | 1 ms | 256 KB |
1_05.txt | AC | 1 ms | 256 KB |
1_06.txt | AC | 1 ms | 256 KB |
1_07.txt | AC | 1 ms | 256 KB |
1_08.txt | AC | 1 ms | 256 KB |
1_09.txt | AC | 1 ms | 256 KB |
1_10.txt | AC | 1 ms | 256 KB |
2_00.txt | AC | 13 ms | 2044 KB |
2_01.txt | AC | 13 ms | 2044 KB |
2_02.txt | AC | 15 ms | 2044 KB |
2_03.txt | AC | 13 ms | 2044 KB |
2_04.txt | AC | 13 ms | 2044 KB |
2_05.txt | AC | 13 ms | 2044 KB |
2_06.txt | AC | 13 ms | 2044 KB |
2_07.txt | AC | 13 ms | 2044 KB |
2_08.txt | AC | 13 ms | 2044 KB |
2_09.txt | AC | 13 ms | 2044 KB |
2_10.txt | AC | 13 ms | 2044 KB |
2_11.txt | AC | 14 ms | 2044 KB |
2_12.txt | AC | 14 ms | 2044 KB |