QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#196832 | #1964. Stock Price Prediction | Forever_Young# | WA | 104ms | 19508kb | C++14 | 1.7kb | 2023-10-02 00:21:16 | 2023-10-02 00:21:17 |
Judging History
answer
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
//typedef tree<pii, null, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define fi first
#define se second
#define pb push_back
#define all(x) ((x).begin()), ((x).end())
const int N = 1000011;
int a[N], b[N];
int x[N], y[N], nxt[N];
bool check(int p, int x[N], int i) {
bool res = (a[p] == 0 || x[i] >= x[i - a[p]]) && (b[p] == 0 || x[i] <= x[i - b[p]]);
//printf("%d %d %d\n", p, i, res);
return res;
}
int main() {
int n, m;
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; i++) {
scanf("%d", &x[i]);
}
for(int j = 1; j <= m; j++) {
scanf("%d", &y[j]);
}
set<pair<int, int> > st;
for(int i = 1; i <= n; i++) {
pii tmp{x[i], i};
auto itr = st.lower_bound(tmp);
if(itr != st.end()) {
b[i] = i - itr->se;
}else {
b[i] = 0;
}
if(itr != st.begin()) {
itr--;
a[i] = i - itr->se;
}else {
a[i] = 0;
}
st.insert(tmp);
//printf("%d %d %d\n", i, a[i], b[i]);
}
nxt[0] = -1;
for(int i = 1; i <= n; i++) {
int p = nxt[i - 1];
while(p != -1 && !check(p + 1, x, i)) {
p = nxt[p];
}
nxt[i] = p + 1;
//printf("nxt[%d] = %d\n", i, nxt[i]);
}
int p = 0;
vector<int> ans;
for(int i = 1; i <= m; i++) {
while(p != -1 && !check(p + 1, y, i)) {
p = nxt[p];
}
p += 1;
if(p == n) {
ans.push_back(i - n + 1);
p = nxt[p];
}else {
}
}
if(ans.empty()) {
printf("0\n");
exit(0);
}
for(int i = 0; i < (int)ans.size(); i++) {
printf("%d%c", ans[i], i == (int)ans.size() - 1 ? '\n' : ' ');
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 104ms
memory: 19508kb
input:
10000 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok single line: '1 2 3 4 5 6 7 8 9 10 11 12 13 ...997 989998 989999 990000 990001'
Test #2:
score: -100
Wrong Answer
time: 55ms
memory: 14508kb
input:
10000 1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
1 2 10002 20002 30002 40002 50002 60002 70002 80002 90002 100002 110002 120002 130002 140002 150002 160002 170002 180002 190002 200002 210002 220002 230002 240002 250002 260002 270002 280002 290002 300002 310002 320002 330002 340002 350002 360002 370002 380002 390002 400002 410002 420002 430002 4400...
result:
wrong answer 1st lines differ - expected: '2 10002 20002 30002 40002 5000...002 950002 960002 970002 980002', found: '1 2 10002 20002 30002 40002 50...002 950002 960002 970002 980002'