답안 #711024

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
711024 2023-03-16T07:21:49 Z becaido Data Transfer (IOI19_transfer) C++17
100 / 100
342 ms 2500 KB
#include <bits/stdc++.h>
#include "transfer.h"
using namespace std;

vector<int> get_attachment(vector<int> source) {
	int n = source.size(), m = __lg(n + 1);
	vector<int> val(m + 1);
	for (int i = 1; i <= n; i++) if (source[i - 1]) {
        for (int j = 0; j < m; j++) if (i >> j & 1) val[j + 1] ^= 1;
        if (__builtin_popcount(i) == 1) val[0] ^= 1;
	}
	return val;
}

vector<int> differ(vector<int> a, vector<int> b) {
    vector<int> p;
    for (int i = 0; i < a.size(); i++) if (a[i] != b[i]) p.emplace_back(i);
    return p;
}

vector<int> retrieve(vector<int> data) {
    int n = (data.size() == 70 ? 63 : 255), m = __lg(n + 1);
    vector<int> val;
    while (data.size() > n) {
        val.emplace_back(data.back());
        data.pop_back();
    }
    reverse(val.begin(), val.end());
    auto p = differ(get_attachment(data), val);
    if (p.size() <= 1) return data;
    int mask = 0;
    for (int i : p) if (i) mask |= 1 << i - 1;
    data[mask - 1] ^= 1;
    return data;
}

Compilation message

transfer.cpp: In function 'std::vector<int> differ(std::vector<int>, std::vector<int>)':
transfer.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = 0; i < a.size(); i++) if (a[i] != b[i]) p.emplace_back(i);
      |                     ~~^~~~~~~~~~
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:24:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |     while (data.size() > n) {
      |            ~~~~~~~~~~~~^~~
transfer.cpp:32:43: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   32 |     for (int i : p) if (i) mask |= 1 << i - 1;
      |                                         ~~^~~
transfer.cpp:22:45: warning: unused variable 'm' [-Wunused-variable]
   22 |     int n = (data.size() == 70 ? 63 : 255), m = __lg(n + 1);
      |                                             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 652 KB Output is correct
2 Correct 4 ms 740 KB Output is correct
3 Correct 4 ms 644 KB Output is correct
4 Correct 4 ms 728 KB Output is correct
5 Correct 5 ms 652 KB Output is correct
6 Correct 7 ms 644 KB Output is correct
7 Correct 7 ms 644 KB Output is correct
8 Correct 6 ms 768 KB Output is correct
9 Correct 7 ms 628 KB Output is correct
10 Correct 7 ms 728 KB Output is correct
11 Correct 6 ms 728 KB Output is correct
12 Correct 6 ms 652 KB Output is correct
13 Correct 6 ms 728 KB Output is correct
14 Correct 5 ms 652 KB Output is correct
15 Correct 5 ms 644 KB Output is correct
16 Correct 6 ms 644 KB Output is correct
17 Correct 5 ms 644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 2448 KB Output is correct
2 Correct 65 ms 2460 KB Output is correct
3 Correct 68 ms 2488 KB Output is correct
4 Correct 75 ms 2444 KB Output is correct
5 Correct 136 ms 2488 KB Output is correct
6 Correct 195 ms 2452 KB Output is correct
7 Correct 249 ms 2488 KB Output is correct
8 Correct 307 ms 2496 KB Output is correct
9 Correct 334 ms 2500 KB Output is correct
10 Correct 335 ms 2488 KB Output is correct
11 Correct 342 ms 2496 KB Output is correct
12 Correct 194 ms 2496 KB Output is correct
13 Correct 193 ms 2492 KB Output is correct
14 Correct 189 ms 2488 KB Output is correct
15 Correct 184 ms 2496 KB Output is correct
16 Correct 193 ms 2488 KB Output is correct
17 Correct 196 ms 2496 KB Output is correct
18 Correct 188 ms 2488 KB Output is correct
19 Correct 182 ms 2492 KB Output is correct