Submission #3790589
Source Code Expand
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<functional> #include<vector> #include<queue> #include<stack> #include<set> #include<map> using namespace std; #define MOD 1000000007 #define f(i,n) for(int i=0;i<int(n);i++) #define N (50000) long long p2[30]; void prpo2(void){ p2[0] = 2; f(i, 29)p2[i + 1] = (p2[i] * p2[i]) % MOD; return; } long long po2(int x){ long long re = 1; f(i,30){ if (x % 2 == 1)re = (re*p2[i]) % MOD; x = x / 2; } return re; } int main(void){ int n; set<int>se; vector<int>v; int x, y; long long cc, dd, aa, bb; long long c[110]; long long d[110]; int a[110]; bool u[110]; f(i, 110){ u[i] = false; c[i] = -1; } prpo2(); scanf("%d", &n); f(i, n){ scanf("%d", &a[i]); if (se.count(a[i]) == 0){ v.push_back(a[i]); se.insert(a[i]); } } v.push_back(0); sort(v.begin(), v.end(), greater<int>()); f(i, v.size()-1){ f(j, n){ if (a[j] >= v[i])u[j] = true; else u[j] = false; } f(j, n){ if (u[j]){ cc = 2; dd = 1; x = j; y = j; while (u[y]){ if (c[y] >= 0){ cc *= c[y]; cc = cc%MOD; aa = ((2 * c[y]) + d[y]) % MOD; dd *= aa; dd = dd%MOD; } else if (c[y] == -1){ dd *= 2; dd = dd%MOD; } y++; } for (int ii = x; ii < y; ii++)c[ii] = -2; dd = (dd - cc + MOD) % MOD; c[x] = cc; d[x] = dd; j = y; } } aa = po2(v[i] - v[i + 1] - 1); f(i, n){ if (c[i] >= 0)c[i] = (c[i] * aa) % MOD; } } aa = (c[0] + d[0]) % MOD; printf("%lld\n", aa); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Histogram Coloring |
User | MPL |
Language | C++14 (GCC 5.4.1) |
Score | 1100 |
Code Size | 1701 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:48:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.cpp:50:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &a[i]); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1100 / 1100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example_0, example_1, example_2, example_3 |
All | bigrand_0, bigrand_1, bigrand_2, bigrand_3, bigrand_4, bigrand_5, bigrand_6, bigrand_7, bigrand_8, bigrand_9, example_0, example_1, example_2, example_3, perm2_0, perm2_1, perm2_2, perm2_3, perm2_4, perm2_5, perm_0, perm_1, perm_2, perm_3, perm_4, perm_5, rand_0, rand_1, rand_2, rand_3, rand_4, rand_5, rand_6, rand_7, rand_8, rand_9, smallc_0, smallc_1, smallc_2, smallc_3, smallc_4, smallc_5, smallc_6, smallc_7, smallc_8, smallc_9 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
bigrand_0 | AC | 1 ms | 256 KB |
bigrand_1 | AC | 1 ms | 256 KB |
bigrand_2 | AC | 1 ms | 256 KB |
bigrand_3 | AC | 1 ms | 256 KB |
bigrand_4 | AC | 1 ms | 256 KB |
bigrand_5 | AC | 1 ms | 256 KB |
bigrand_6 | AC | 1 ms | 256 KB |
bigrand_7 | AC | 1 ms | 256 KB |
bigrand_8 | AC | 1 ms | 256 KB |
bigrand_9 | AC | 1 ms | 256 KB |
example_0 | AC | 1 ms | 256 KB |
example_1 | AC | 1 ms | 256 KB |
example_2 | AC | 1 ms | 256 KB |
example_3 | AC | 1 ms | 256 KB |
perm2_0 | AC | 1 ms | 256 KB |
perm2_1 | AC | 1 ms | 256 KB |
perm2_2 | AC | 1 ms | 256 KB |
perm2_3 | AC | 1 ms | 256 KB |
perm2_4 | AC | 1 ms | 256 KB |
perm2_5 | AC | 1 ms | 256 KB |
perm_0 | AC | 1 ms | 256 KB |
perm_1 | AC | 1 ms | 256 KB |
perm_2 | AC | 1 ms | 256 KB |
perm_3 | AC | 1 ms | 256 KB |
perm_4 | AC | 1 ms | 256 KB |
perm_5 | AC | 1 ms | 256 KB |
rand_0 | AC | 1 ms | 256 KB |
rand_1 | AC | 1 ms | 256 KB |
rand_2 | AC | 1 ms | 256 KB |
rand_3 | AC | 1 ms | 256 KB |
rand_4 | AC | 1 ms | 256 KB |
rand_5 | AC | 1 ms | 256 KB |
rand_6 | AC | 1 ms | 256 KB |
rand_7 | AC | 1 ms | 256 KB |
rand_8 | AC | 1 ms | 256 KB |
rand_9 | AC | 1 ms | 256 KB |
smallc_0 | AC | 1 ms | 256 KB |
smallc_1 | AC | 1 ms | 256 KB |
smallc_2 | AC | 1 ms | 256 KB |
smallc_3 | AC | 1 ms | 256 KB |
smallc_4 | AC | 1 ms | 256 KB |
smallc_5 | AC | 1 ms | 256 KB |
smallc_6 | AC | 1 ms | 256 KB |
smallc_7 | AC | 1 ms | 256 KB |
smallc_8 | AC | 1 ms | 256 KB |
smallc_9 | AC | 1 ms | 256 KB |