// =================================
// author: memset0
// date: 2019.07.16 08:30:00
// website: https://memset0.cn/
// =================================
#include <bits/stdc++.h>
#define ll long long
#define rep(i, l, r) for (int i = (l), i##ed = (r); i <= i##ed; ++i)
#define for_each(i, a) for (size_t i = 0, i##ed = a.size(); i < i##ed; ++i)
namespace ringo {
template <class T> inline void read(T &x) {
x = 0; char c = getchar(); bool f = 0;
while (!isdigit(c)) f ^= c == '-', c = getchar();
while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
if (f) x = -x;
}
template <class T> inline void print(T x) {
if (x < 0) putchar('-'), x = -x;
if (x > 9) print(x / 10);
putchar('0' + x % 10);
}
template <class T> inline void print(T x, char c) { print(x), putchar(c); }
template <class T> inline void print(T a, int l, int r, std::string s = "") {
if (s != "") std::cout << s << ": ";
for (int i = l; i <= r; i++) print(a[i], " \n"[i == r]);
}
const int N = 10;
int n, ans, a[N], l[N], r[N];
bool check() {
for (int i = 1; i <= n; i++) {
int l = i, r = i;
while (l > 1 && a[l - 1] <= a[i]) --l;
while (r < n && a[r + 1] < a[i]) ++r;
if (std::abs((r - i) - (i - l)) > 2)
return false;
}
return true;
}
bool check2() {
for (int i = 1; i <= n; i += n - 1) {
int l = i, r = i;
while (l > 1 && a[l - 1] <= a[i]) --l;
while (r < n && a[r + 1] < a[i]) ++r;
if (std::abs((r - i) - (i - l)) > 2)
return false;
}
return true;
}
void dfs(int u) {
if (u > n) {
ans += check();
// ans += check2();
// if (check() != check2()) {
// printf("> %d %d\n", check(), check2());
// for (int i = 1; i <= n; i++)
// print(a[i], " \n"[i == n]);
// exit(0);
// }
return;
}
for (int i = l[u]; i <= r[u]; i++) {
a[u] = i;
dfs(u + 1);
}
}
void main() {
read(n);
for (int i = 1; i <= n; i++) {
read(l[i]), read(r[i]);
}
dfs(1);
print(ans, '\n');
}
} signed main() {
#ifdef memset0
freopen("robot2.in", "r", stdin);
#else
freopen("robot.in", "r", stdin);
freopen("robot.out", "w", stdout);
#endif
return ringo::main(), 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 33.62 us | 36 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #2 | 40.96 us | 36 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #3 | 113.36 us | 36 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #4 | 86.06 us | 36 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #5 | 1.668 ms | 36 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #6 | 35.23 us | 36 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #7 | 34.62 us | 36 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #8 | 3 s | 32 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Testcase #9 | 3 s | 32 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Testcase #10 | 3 s | 32 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Testcase #11 | 34.1 us | 36 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #12 | 34.02 us | 36 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #13 | 3 s | 32 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Testcase #14 | 3 s | 32 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Testcase #15 | 3 s | 32 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Testcase #16 | 3 s | 32 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Testcase #17 | 3 s | 32 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Testcase #18 | 3 s | 32 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Testcase #19 | 3 s | 32 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
| Testcase #20 | 3 s | 32 KB | Time Limit Exceeded | Score: 0 | 显示更多 |