# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
457970 |
2021-08-07T16:24:08 Z |
mansur |
Rack (eJOI19_rack) |
C++14 |
|
38 ms |
4300 KB |
#include<bits/stdc++.h>
#pragma optimize ("g",on)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("03")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
using namespace std;
#define all(a) a.begin(), a.end()
#define ll long long
#define pb push_back
#define nl '\n'
#define popb pop_back()
#define sz size()
#define ld long double
#define ull unsigned long long
#define F first
#define S second
#define fix fixed << setprecision
#define pii pair<int, int>
#define E exit (0)
#define int long long
const int inf = (1ll << 62ll), N = 1e6 + 1, mod = 998244353;
vector<pii> dd = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int t[N];
void update(int u, int tl, int tr, int pos) {
if (tl > pos || tr < pos) return;
if (tl == tr) {
t[u] = 1;
return;
}
int mid = (tl + tr) / 2;
update(u * 2, tl, mid, pos);
update(u * 2 + 1, mid + 1, tr, pos);
t[u] = t[u * 2] + t[u * 2 + 1];
}
int get(int u, int tl, int tr) {
if (tl == tr) return tl;
int mid = (tl + tr) / 2;
if (t[u * 2 + 1] < t[u * 2]) return get(u * 2 + 1, mid + 1, tr);
return get(u * 2, tl, mid);
}
signed main() {
//freopen("invtrans.in", "r", stdin);
//freopen("invtrans.out", "w", stdout);
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
int n, k;
cin >> n >> k;
n = (1 << n);
for (int i = 1; i <= k; i++) {
int pos = get(1, 1, n);
update(1, 1, n, pos);
if (i == k) cout << pos;
}
}
Compilation message
rack.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
3 | #pragma optimize ("g",on)
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
316 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
17 ms |
1228 KB |
Output is correct |
9 |
Correct |
38 ms |
4300 KB |
Output is correct |
10 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 11 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
316 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
17 ms |
1228 KB |
Output is correct |
9 |
Correct |
38 ms |
4300 KB |
Output is correct |
10 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 11 |