# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1052281 |
2024-08-10T12:59:45 Z |
Nickpapadak |
Rack (eJOI19_rack) |
C++14 |
|
3 ms |
2136 KB |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const unsigned ll MAXN = 2e+6 + 10;
long long N,N2, K;
const unsigned ll MOD = 1e+9 + 7;
// ll seg[4*MAXN];
stack<ll> q;
// int Update(int low, int high, int i, int indx){
// if(low > i || high < i) return seg[indx];
// if(low == high && low == i) {
// seg[indx] = 1;
// return seg[indx];
// }
// int mid = (low+high)>>1;
// seg[indx] = Update(low, mid, i, 2*indx) - Update(mid+1, high, i, 2*indx+1);
// return seg[indx];
// }
// int findInbalance(ll indx){
// if(seg[2*indx]) return findInbalance(2*indx);
// if(seg[2*indx+1]) return findInbalance(2*indx+1);
// return indx;
// }
ll AddToQueue(ll i, ll add){
// if(q.size() == K){
// printf("%lld ", q.top());
// return 1;
// }
// ll s = N2 - add; // 2
ll NN2 = N2; // 3
while(NN2 > add){
if((ll) q.size() == K){
printf("%lld", q.top());
return 1;
}
q.push((i+NN2) % MOD);
if(AddToQueue((i+NN2) % MOD, NN2)) return 1;
// s = s>>1;
NN2 = NN2 >>1;
}
return 0;
}
int main(){
scanf("%lld%lld", &N, &K);
N2 = 1 << (N-1);
q.push(1);
// printf("%lld\n", N2);
AddToQueue(1, 0);
// for(int i = 1; i < K; ++i){s
return 0;
}
Compilation message
rack.cpp: In function 'int main()':
rack.cpp:48:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
48 | scanf("%lld%lld", &N, &K);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
3 ms |
2136 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
3 ms |
2136 KB |
Output is correct |
11 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |