Submission #577223

# Submission time Handle Problem Language Result Execution time Memory
577223 2022-06-14T09:45:48 Z dozer Rack (eJOI19_rack) C++14
40 / 100
1 ms 316 KB
#include <bits/stdc++.h>
using namespace std;
#define sp " "
#define endl "\n"
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define N 200005
#define L(node) node * 2
#define R(node) node * 2 + 1
#define int long long

const int modulo = 1e9 + 7; 
int n, arr[1];

int fe(int a, int b)
{
	if (b == 0) return 1;
	if (b % 2 == 1) return (b * fe(a, b - 1)) % modulo;
	int tmp = fe(a, b / 2);
	return (tmp * tmp) % modulo;
}

int f(int k, int level)
{
	if (k == 1) return 1;
	if (level >= 64 || k <= 0) return arr[1];
	int odd = 0;
	if (level <= 62 && k % ((long long)1<<level) == 1) odd = 1;
	if (odd) return f(k, level + 1);
	return (f(k - ((long long)1<<(level - 1)), level + 1) + ((long long)1<<(n - level)) % modulo) % modulo;
}

int32_t main()
{
	fastio();

	int k;
	cin>>n>>k;
	cout<<f(k, 1)<<endl;

	cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}

Compilation message

rack.cpp: In function 'long long int f(long long int, long long int)':
rack.cpp:30:41: warning: array subscript 1 is above array bounds of 'long long int [1]' [-Warray-bounds]
   30 |  if (level >= 64 || k <= 0) return arr[1];
      |                                    ~~~~~^
rack.cpp:17:8: note: while referencing 'arr'
   17 | int n, arr[1];
      |        ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Incorrect 0 ms 316 KB Output isn't correct
13 Halted 0 ms 0 KB -