답안 #957017

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
957017 2024-04-02T19:37:33 Z pragmatist Xoractive (IZhO19_xoractive) C++17
80 / 100
4 ms 612 KB
#include "interactive.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> guess(int n) {
	vector<int> ans(n+1, -1);
	map<int, int> cnt[10];
	for(int i = 1; i <= n; i *= 2) {
		ans[i] = ask(i);
	}
	for(int i = 0; (1<<i) <= n; ++i) {
		vector<int> ind;
		for(int j = 1; j <= n; ++j) {
			if(j >> i & 1) {
				ind.push_back(j);
			}
		}
		if((int)ind.size() == 1) {
			continue;
		}
		assert(!ind.empty());
		for(int j = 0; j < (int)ind.size(); ++j) {
			if(ans[ind[j]] != -1) {
				ind.insert(ind.begin(), ind[j]);
				ind.erase(ind.begin()+j+1);
				break;
			}
		}
		int st = ans[ind[0]];
		map<int, int> cur;
		vector<int> c1 = get_pairwise_xor(ind);
		for(auto x : c1) {
			cur[x]++;
		}
		ind.erase(ind.begin());
		if((int)ind.size() == 2) {
			ans[ind[0]] = (c1.back()^st);
			continue;
		}
		vector<int> c2 = get_pairwise_xor(ind);
		for(auto x : c2) {
			cur[x]--;
		}
		vector<int> v;
		for(auto e : cur) {
			if(e.second == 0) {
				continue;
			}
			v.push_back(e.first^st);
		}
		for(auto x : v) {
			cnt[i][x]++;
		}
	}
	for(int i = n; i >= 1; --i) {
		if(ans[i] != -1) {
			continue;
		}
		map<int, int> cur;
		int tot = 0;
		for(int j = 0; (1 << j) <= i; ++j) {
			if(i >> j & 1) {
				tot++;
				for(auto e : cnt[j]) {
					cur[e.first]++;
				}
			}
		}
		for(auto e : cur) {
			if(e.second == tot) {
				ans[i] = e.first;
			}
		}
		for(int j = 0; (1 << j) <= i; ++j) {
			if(i >> j & 1) {
				cnt[j].erase(ans[i]);
			}
		}
	}
	ans.erase(ans.begin());
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 3 ms 344 KB Output is partially correct
2 Partially correct 3 ms 344 KB Output is partially correct
3 Partially correct 2 ms 344 KB Output is partially correct
4 Partially correct 3 ms 344 KB Output is partially correct
5 Partially correct 3 ms 344 KB Output is partially correct
6 Partially correct 3 ms 344 KB Output is partially correct
7 Partially correct 2 ms 500 KB Output is partially correct
8 Partially correct 4 ms 536 KB Output is partially correct
9 Partially correct 4 ms 344 KB Output is partially correct
10 Partially correct 3 ms 344 KB Output is partially correct
11 Partially correct 2 ms 492 KB Output is partially correct
12 Partially correct 3 ms 524 KB Output is partially correct
13 Partially correct 3 ms 344 KB Output is partially correct
14 Partially correct 3 ms 540 KB Output is partially correct
15 Partially correct 2 ms 344 KB Output is partially correct
16 Partially correct 3 ms 344 KB Output is partially correct
17 Partially correct 3 ms 344 KB Output is partially correct
18 Partially correct 3 ms 344 KB Output is partially correct
19 Partially correct 3 ms 344 KB Output is partially correct
20 Partially correct 3 ms 344 KB Output is partially correct
21 Partially correct 4 ms 344 KB Output is partially correct
22 Partially correct 3 ms 344 KB Output is partially correct
23 Partially correct 2 ms 344 KB Output is partially correct
24 Partially correct 3 ms 344 KB Output is partially correct
25 Partially correct 3 ms 344 KB Output is partially correct
26 Partially correct 3 ms 344 KB Output is partially correct
27 Partially correct 2 ms 344 KB Output is partially correct
28 Partially correct 3 ms 344 KB Output is partially correct
29 Partially correct 4 ms 344 KB Output is partially correct
30 Partially correct 3 ms 344 KB Output is partially correct
31 Partially correct 2 ms 344 KB Output is partially correct
32 Partially correct 3 ms 344 KB Output is partially correct
33 Partially correct 3 ms 344 KB Output is partially correct
34 Partially correct 3 ms 344 KB Output is partially correct
35 Partially correct 3 ms 600 KB Output is partially correct
36 Partially correct 3 ms 344 KB Output is partially correct
37 Partially correct 3 ms 540 KB Output is partially correct
38 Partially correct 3 ms 344 KB Output is partially correct
39 Partially correct 2 ms 344 KB Output is partially correct
40 Partially correct 4 ms 344 KB Output is partially correct
41 Partially correct 3 ms 344 KB Output is partially correct
42 Partially correct 4 ms 344 KB Output is partially correct
43 Partially correct 3 ms 344 KB Output is partially correct
44 Partially correct 3 ms 344 KB Output is partially correct
45 Partially correct 3 ms 344 KB Output is partially correct
46 Partially correct 3 ms 344 KB Output is partially correct
47 Partially correct 2 ms 344 KB Output is partially correct
48 Partially correct 4 ms 532 KB Output is partially correct
49 Partially correct 3 ms 532 KB Output is partially correct
50 Partially correct 3 ms 344 KB Output is partially correct
51 Partially correct 2 ms 344 KB Output is partially correct
52 Partially correct 3 ms 344 KB Output is partially correct
53 Partially correct 3 ms 344 KB Output is partially correct
54 Partially correct 3 ms 344 KB Output is partially correct
55 Partially correct 2 ms 344 KB Output is partially correct
56 Partially correct 4 ms 344 KB Output is partially correct
57 Partially correct 4 ms 344 KB Output is partially correct
58 Partially correct 3 ms 344 KB Output is partially correct
59 Partially correct 2 ms 344 KB Output is partially correct
60 Partially correct 3 ms 344 KB Output is partially correct
61 Partially correct 3 ms 344 KB Output is partially correct
62 Partially correct 3 ms 344 KB Output is partially correct
63 Partially correct 3 ms 344 KB Output is partially correct
64 Partially correct 4 ms 344 KB Output is partially correct
65 Partially correct 3 ms 548 KB Output is partially correct
66 Partially correct 4 ms 612 KB Output is partially correct
67 Partially correct 2 ms 344 KB Output is partially correct
68 Partially correct 3 ms 344 KB Output is partially correct
69 Partially correct 3 ms 344 KB Output is partially correct
70 Partially correct 3 ms 344 KB Output is partially correct
71 Partially correct 2 ms 344 KB Output is partially correct
72 Partially correct 3 ms 344 KB Output is partially correct
73 Partially correct 3 ms 344 KB Output is partially correct
74 Partially correct 4 ms 344 KB Output is partially correct
75 Partially correct 2 ms 344 KB Output is partially correct
76 Partially correct 3 ms 344 KB Output is partially correct
77 Partially correct 3 ms 344 KB Output is partially correct
78 Partially correct 3 ms 344 KB Output is partially correct
79 Partially correct 2 ms 344 KB Output is partially correct
80 Partially correct 3 ms 540 KB Output is partially correct
81 Partially correct 3 ms 344 KB Output is partially correct
82 Partially correct 3 ms 344 KB Output is partially correct
83 Partially correct 2 ms 496 KB Output is partially correct
84 Partially correct 4 ms 344 KB Output is partially correct
85 Partially correct 3 ms 344 KB Output is partially correct
86 Partially correct 3 ms 344 KB Output is partially correct
87 Partially correct 2 ms 344 KB Output is partially correct
88 Partially correct 3 ms 344 KB Output is partially correct
89 Partially correct 3 ms 344 KB Output is partially correct
90 Partially correct 3 ms 544 KB Output is partially correct
91 Partially correct 2 ms 344 KB Output is partially correct
92 Partially correct 4 ms 532 KB Output is partially correct
93 Partially correct 3 ms 344 KB Output is partially correct
94 Partially correct 3 ms 344 KB Output is partially correct
95 Partially correct 2 ms 344 KB Output is partially correct
96 Partially correct 3 ms 344 KB Output is partially correct
97 Partially correct 3 ms 344 KB Output is partially correct
98 Partially correct 3 ms 344 KB Output is partially correct
99 Partially correct 2 ms 344 KB Output is partially correct
100 Partially correct 3 ms 344 KB Output is partially correct