Submission #742276

# Submission time Handle Problem Language Result Execution time Memory
742276 2023-05-16T03:56:39 Z josanneo22 Rack (eJOI19_rack) C++17
0 / 100
1 ms 324 KB
#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second 
#define int long long

vector<int> merge(vector<int>& a, vector<int>& b) {
	vector<int> ans; 
	vector<int> oda, odb, eva, evb;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] % 2 == 1) oda.pb(a[i]);
		else eva.pb(a[i]);
	}
	for (int i = 0; i < b.size(); i++) {
		if (b[i] % 2 == 1) odb.pb(b[i]);
		else evb.pb(b[i]);
	}
	int pt = 0, chance = 0;
	while (pt < oda.size()) {
		if (chance == 0 && oda.size() > pt) ans.pb(oda[pt]);
		else if (chance==1 && odb.size() > pt)ans.pb(odb[pt]);
		if (chance == 1) pt++;
		chance = 1 - chance;
	}
	pt = 0, chance = 0;
	while (pt < eva.size()) {
		if (chance == 0 && eva.size() > pt) ans.pb(eva[pt]);
		else if (chance == 1 && evb.size() > pt)ans.pb(evb[pt]);
		if (chance == 1) pt++;
		chance = 1 - chance;
	}
	return ans;
}
vector<int> call(int l, int r) {
	if (r < l) return {};
	if (r == l) return { l };
	else {
		int md = (l+r) / 2;
		vector<int> a = call(l, md), b = call(md + 1, r);
		return merge(a, b);
	}
}
void solve() {
	int n, k; cin >> n >> k;
	vector<int> ans = call(1, 1<<n);
	cout << ans[k-1] << '\n';
}
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	solve();
}

Compilation message

rack.cpp: In function 'std::vector<long long int> merge(std::vector<long long int>&, std::vector<long long int>&)':
rack.cpp:14:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for (int i = 0; i < a.size(); i++) {
      |                  ~~^~~~~~~~~~
rack.cpp:18:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for (int i = 0; i < b.size(); i++) {
      |                  ~~^~~~~~~~~~
rack.cpp:23:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  while (pt < oda.size()) {
      |         ~~~^~~~~~~~~~~~
rack.cpp:24:33: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   24 |   if (chance == 0 && oda.size() > pt) ans.pb(oda[pt]);
      |                      ~~~~~~~~~~~^~~~
rack.cpp:25:36: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   25 |   else if (chance==1 && odb.size() > pt)ans.pb(odb[pt]);
      |                         ~~~~~~~~~~~^~~~
rack.cpp:30:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  while (pt < eva.size()) {
      |         ~~~^~~~~~~~~~~~
rack.cpp:31:33: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   31 |   if (chance == 0 && eva.size() > pt) ans.pb(eva[pt]);
      |                      ~~~~~~~~~~~^~~~
rack.cpp:32:38: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   32 |   else if (chance == 1 && evb.size() > pt)ans.pb(evb[pt]);
      |                           ~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Incorrect 1 ms 320 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Incorrect 1 ms 320 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Incorrect 1 ms 320 KB Output isn't correct
5 Halted 0 ms 0 KB -