# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
201812 |
2020-02-12T05:26:52 Z |
tri |
Xylophone (JOI18_xylophone) |
C++14 |
|
105 ms |
504 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
#define pb push_back
#define f first
#define s second
namespace debug {
const int DEBUG = true;
template<class T1, class T2>
void pr(const pair<T1, T2> &x);
template<class T, size_t SZ>
void pr(const array<T, SZ> &x);
template<class T>
void pr(const vector<T> &x);
template<class T>
void pr(const set<T> &x);
template<class T1, class T2>
void pr(const map<T1, T2> &x);
template<class T>
void pr(const T &x) { if (DEBUG) cout << x; }
template<class T, class... Ts>
void pr(const T &first, const Ts &... rest) { pr(first), pr(rest...); }
template<class T1, class T2>
void pr(const pair<T1, T2> &x) { pr("{", x.f, ", ", x.s, "}"); }
template<class T>
void prIn(const T &x) {
pr("{");
bool fst = 1;
for (auto &a : x) {
pr(fst ? "" : ", ", a), fst = 0;
}
pr("}");
}
template<class T, size_t SZ>
void pr(const array<T, SZ> &x) { prIn(x); }
template<class T>
void pr(const vector<T> &x) { prIn(x); }
template<class T>
void pr(const set<T> &x) { prIn(x); }
template<class T1, class T2>
void pr(const map<T1, T2> &x) { prIn(x); }
void ps() { pr("\n"), cout << flush; }
template<class Arg, class... Args>
void ps(const Arg &first, const Args &... rest) {
pr(first, " ");
ps(rest...);
}
}
using namespace debug;
int query(int s, int t);
void answer(int i, int a);
void solve(int N) {
vi sDiff(N + 1), dDiff(N + 1);
for (int i = 1; i <= N; i++) {
if (i + 1 <= N) {
sDiff[i] = query(i, i + 1);
}
if (i + 2 <= N) {
dDiff[i] = query(i, i + 2);
}
}
vi a(N + 1);
a[1] = 0;
a[2] = sDiff[1];
for (int i = 3; i <= N; i++) {
bool lUp = a[i - 1] > a[i - 2];
bool cUp;
if (sDiff[i - 2] + sDiff[i - 1] == dDiff[i - 2]) {
cUp = lUp;
} else {
cUp = !lUp;
}
if (cUp) {
a[i] = a[i - 1] + sDiff[i - 1];
} else {
a[i] = a[i - 1] - sDiff[i - 1];
}
}
int minV = 1e9;
for (int i = 1; i <= N; i++) {
minV = min(minV, a[i]);
}
int delta = 1 - minV;
for (int i = 1; i <= N; i++) {
a[i] += delta;
}
int minI = min_element(++a.begin(), a.end()) - a.begin();
int maxI = max_element(++a.begin(), a.end()) - a.begin();
if (minI > maxI) {
for (int i = 1; i <= N; i++) {
a[i] = N + 1 - a[i];
}
}
for (int i = 1; i <= N; i++) {
answer(i, a[i]);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
252 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
7 ms |
248 KB |
Output is correct |
5 |
Correct |
6 ms |
248 KB |
Output is correct |
6 |
Correct |
7 ms |
248 KB |
Output is correct |
7 |
Correct |
7 ms |
248 KB |
Output is correct |
8 |
Correct |
7 ms |
248 KB |
Output is correct |
9 |
Correct |
7 ms |
248 KB |
Output is correct |
10 |
Correct |
7 ms |
248 KB |
Output is correct |
11 |
Correct |
6 ms |
376 KB |
Output is correct |
12 |
Correct |
6 ms |
248 KB |
Output is correct |
13 |
Correct |
6 ms |
248 KB |
Output is correct |
14 |
Correct |
6 ms |
248 KB |
Output is correct |
15 |
Correct |
7 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
252 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
7 ms |
248 KB |
Output is correct |
5 |
Correct |
6 ms |
248 KB |
Output is correct |
6 |
Correct |
7 ms |
248 KB |
Output is correct |
7 |
Correct |
7 ms |
248 KB |
Output is correct |
8 |
Correct |
7 ms |
248 KB |
Output is correct |
9 |
Correct |
7 ms |
248 KB |
Output is correct |
10 |
Correct |
7 ms |
248 KB |
Output is correct |
11 |
Correct |
6 ms |
376 KB |
Output is correct |
12 |
Correct |
6 ms |
248 KB |
Output is correct |
13 |
Correct |
6 ms |
248 KB |
Output is correct |
14 |
Correct |
6 ms |
248 KB |
Output is correct |
15 |
Correct |
7 ms |
376 KB |
Output is correct |
16 |
Correct |
10 ms |
376 KB |
Output is correct |
17 |
Correct |
14 ms |
376 KB |
Output is correct |
18 |
Correct |
18 ms |
248 KB |
Output is correct |
19 |
Correct |
14 ms |
324 KB |
Output is correct |
20 |
Correct |
22 ms |
248 KB |
Output is correct |
21 |
Correct |
21 ms |
328 KB |
Output is correct |
22 |
Correct |
22 ms |
248 KB |
Output is correct |
23 |
Correct |
23 ms |
248 KB |
Output is correct |
24 |
Correct |
22 ms |
376 KB |
Output is correct |
25 |
Correct |
22 ms |
248 KB |
Output is correct |
26 |
Correct |
20 ms |
248 KB |
Output is correct |
27 |
Correct |
14 ms |
328 KB |
Output is correct |
28 |
Correct |
14 ms |
324 KB |
Output is correct |
29 |
Correct |
23 ms |
248 KB |
Output is correct |
30 |
Correct |
23 ms |
248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
252 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
7 ms |
248 KB |
Output is correct |
5 |
Correct |
6 ms |
248 KB |
Output is correct |
6 |
Correct |
7 ms |
248 KB |
Output is correct |
7 |
Correct |
7 ms |
248 KB |
Output is correct |
8 |
Correct |
7 ms |
248 KB |
Output is correct |
9 |
Correct |
7 ms |
248 KB |
Output is correct |
10 |
Correct |
7 ms |
248 KB |
Output is correct |
11 |
Correct |
6 ms |
376 KB |
Output is correct |
12 |
Correct |
6 ms |
248 KB |
Output is correct |
13 |
Correct |
6 ms |
248 KB |
Output is correct |
14 |
Correct |
6 ms |
248 KB |
Output is correct |
15 |
Correct |
7 ms |
376 KB |
Output is correct |
16 |
Correct |
10 ms |
376 KB |
Output is correct |
17 |
Correct |
14 ms |
376 KB |
Output is correct |
18 |
Correct |
18 ms |
248 KB |
Output is correct |
19 |
Correct |
14 ms |
324 KB |
Output is correct |
20 |
Correct |
22 ms |
248 KB |
Output is correct |
21 |
Correct |
21 ms |
328 KB |
Output is correct |
22 |
Correct |
22 ms |
248 KB |
Output is correct |
23 |
Correct |
23 ms |
248 KB |
Output is correct |
24 |
Correct |
22 ms |
376 KB |
Output is correct |
25 |
Correct |
22 ms |
248 KB |
Output is correct |
26 |
Correct |
20 ms |
248 KB |
Output is correct |
27 |
Correct |
14 ms |
328 KB |
Output is correct |
28 |
Correct |
14 ms |
324 KB |
Output is correct |
29 |
Correct |
23 ms |
248 KB |
Output is correct |
30 |
Correct |
23 ms |
248 KB |
Output is correct |
31 |
Correct |
38 ms |
340 KB |
Output is correct |
32 |
Correct |
54 ms |
504 KB |
Output is correct |
33 |
Correct |
74 ms |
352 KB |
Output is correct |
34 |
Correct |
100 ms |
364 KB |
Output is correct |
35 |
Correct |
86 ms |
376 KB |
Output is correct |
36 |
Correct |
87 ms |
376 KB |
Output is correct |
37 |
Correct |
105 ms |
376 KB |
Output is correct |
38 |
Correct |
92 ms |
376 KB |
Output is correct |
39 |
Correct |
79 ms |
376 KB |
Output is correct |
40 |
Correct |
90 ms |
376 KB |
Output is correct |
41 |
Correct |
93 ms |
376 KB |
Output is correct |
42 |
Correct |
82 ms |
376 KB |
Output is correct |
43 |
Correct |
92 ms |
504 KB |
Output is correct |
44 |
Correct |
95 ms |
376 KB |
Output is correct |
45 |
Correct |
96 ms |
504 KB |
Output is correct |
46 |
Correct |
101 ms |
376 KB |
Output is correct |
47 |
Correct |
94 ms |
376 KB |
Output is correct |
48 |
Correct |
86 ms |
504 KB |
Output is correct |
49 |
Correct |
102 ms |
376 KB |
Output is correct |
50 |
Correct |
103 ms |
376 KB |
Output is correct |
51 |
Correct |
91 ms |
376 KB |
Output is correct |
52 |
Correct |
101 ms |
376 KB |
Output is correct |
53 |
Correct |
94 ms |
376 KB |
Output is correct |
54 |
Correct |
72 ms |
356 KB |
Output is correct |
55 |
Correct |
96 ms |
376 KB |
Output is correct |
56 |
Correct |
95 ms |
376 KB |
Output is correct |
57 |
Correct |
91 ms |
376 KB |
Output is correct |
58 |
Correct |
90 ms |
376 KB |
Output is correct |
59 |
Correct |
105 ms |
376 KB |
Output is correct |
60 |
Correct |
92 ms |
504 KB |
Output is correct |