QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#554971 | #9220. Bus Analysis | MiniLong | WA | 930ms | 17436kb | C++17 | 3.6kb | 2024-09-09 18:32:03 | 2024-09-09 18:32:04 |
Judging History
answer
#include <bits/stdc++.h>
#define _rep(i, x, y) for(int i = x; i <= y; ++i)
#define _req(i, x, y) for(int i = x; i >= y; --i)
#define _rev(i, u) for(int i = head[u]; i; i = e[i].nxt)
#define pb push_back
#define fi first
#define se second
#define mst(f, i) memset(f, i, sizeof f)
using namespace std;
#ifdef ONLINE_JUDGE
#define debug(...) 0
#else
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#endif
typedef long long ll;
typedef pair<ll, ll> PII;
namespace fastio{
#ifdef ONLINE_JUDGE
char ibuf[1 << 20],*p1 = ibuf, *p2 = ibuf;
#define get() p1 == p2 && (p2 = (p1 = ibuf) + fread(ibuf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++
#else
#define get() getchar()
#endif
template<typename T> inline void read(T &t){
T x = 0, f = 1;
char c = getchar();
while(!isdigit(c)){
if(c == '-') f = -f;
c = getchar();
}
while(isdigit(c)) x = x * 10 + c - '0', c = getchar();
t = x * f;
}
template<typename T, typename ... Args> inline void read(T &t, Args&... args){
read(t);
read(args...);
}
template<typename T> void write(T t){
if(t < 0) putchar('-'), t = -t;
if(t >= 10) write(t / 10);
putchar(t % 10 + '0');
}
template<typename T, typename ... Args> void write(T t, Args... args){
write(t), putchar(' '), write(args...);
}
template<typename T> void writeln(T t){
write(t);
puts("");
}
template<typename T> void writes(T t){
write(t), putchar(' ');
}
#undef get
};
using namespace fastio;
#define multitest() int T; read(T); _rep(tCase, 1, T)
namespace Calculation{
const ll mod = 1e9 + 7;
ll ksm(ll p, ll h){ll base = p % mod, res = 1; while(h){if(h & 1ll) res = res * base % mod; base = base * base % mod, h >>= 1ll;} return res;}
void dec(ll &x, ll y){x = ((x - y) % mod + mod) % mod;}
void add(ll &x, ll y){x = (x + y) % mod;}
void mul(ll &x, ll y){x = x * y % mod;}
ll sub(ll x, ll y){return ((x - y) % mod + mod) % mod;}
ll pls(ll x, ll y){return ((x + y) % mod + mod) % mod;}
ll mult(ll x, ll y){return x * y % mod;}
}
using namespace Calculation;
const int N = 1005;
int n, a[N], nxt[N], nxt2[N], nxt3[N];
ll pw[N];
PII f[N][N], g[N];
void work(PII &x, PII y, PII t){
add(x.fi, y.fi * t.fi % mod);
add(x.se, y.fi * t.se % mod + y.se * t.fi % mod);
}
int main(){
read(n), pw[0] = 1;
_rep(i, 1, n) pw[i] = pw[i - 1] * 2 % mod;
_rep(i, 1, n) read(a[i]);
_rep(i, 1, n) _rep(j, i, n){
if(a[i] + 20 > a[j]) nxt[i] = j;
if(a[i] + 75 > a[j]) nxt2[i] = j;
if(a[i] + 75 >= a[j] + 20) nxt3[i] = j;
}
ll ans = 0;
_rep(i, 1, n){
PII c = {pw[nxt[i] - i], 2 * pw[nxt[i] - i] % mod};
f[i][0] = c;
_rep(j, 1, i - 1) work(f[i][0], g[j], c);
_rep(j, 1, i - 1){
if(nxt[j] >= i) continue;
_rep(k, 0, j - 1){
if(!k || a[k] + 75 < a[i] + 20){
work(f[i][j], f[j][k], c);
}
}
if(nxt3[j] >= nxt[i] + 1){
int len = nxt3[j] - nxt[i], len2 = nxt2[j] - nxt3[j];
PII cur = {sub(pw[len], 1) * pw[len2] % mod, 2 * sub(pw[len], 1) * pw[len2] % mod};
work(g[nxt2[j]], f[i][j], cur);
}
}
add(ans, g[i].se);
_rep(j, 0, i - 1){
add(ans, f[i][j].se);
debug("f(%d,%d):(num:%d,val:%d)\n", i, j, f[i][j].fi, f[i][j].se);
}
}
writeln(ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3716kb
input:
3 1 8 20
output:
14
result:
ok 1 number(s): "14"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5596kb
input:
5 25 45 65 85 1000000000
output:
156
result:
ok 1 number(s): "156"
Test #3:
score: -100
Wrong Answer
time: 930ms
memory: 17436kb
input:
1000 2 7 9 12 14 17 18 21 22 28 29 33 34 35 37 38 44 45 46 50 58 59 63 66 71 72 75 76 77 78 80 81 83 84 87 92 100 101 107 108 109 112 114 116 118 123 124 131 142 143 144 145 148 150 151 152 153 155 157 158 165 167 168 169 171 176 182 185 190 192 198 202 204 205 212 213 223 224 225 226 229 231 240 24...
output:
208687381
result:
wrong answer 1st numbers differ - expected: '932594593', found: '208687381'