답안 #679332

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
679332 2023-01-08T04:07:07 Z Magikarp4000 Data Transfer (IOI19_transfer) C++17
100 / 100
60 ms 2500 KB
#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;
#define OPTM ios_base::sync_with_stdio(0); cin.tie(0);
#define INF int(1e9+7)
#define ln '\n'
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define FOR(i,s,n) for (int i = s; i < n; i++)
#define FORR(i,n,s) for (int i = n; i > s; i--)
#define FORX(u, arr) for (auto u : arr)
#define PB push_back
#define in(v,x) (v.find(x) != v.end())
#define F first
#define S second
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define UM unordered_map
#define US unordered_set
#define PQ priority_queue
#define ALL(v) v.begin(), v.end()
const ll LLINF = 1e18+1;

std::vector<int> get_attachment(std::vector<int> s) {
    int n = s.size();
    int k = 0, p = 0;
    FOR(i,0,n) {
        if (s[i] == 1) k ^= (i+1);
    }
    vector<int> res;
    int i = 0;
    while ((1<<i) <= k) {
        if (k&(1<<i)) res.PB(1);
        else res.PB(0);
        i++;
    }
	FOR(j,0,6-i) res.PB(0);
	int cnt = 0;
	FORX(u,res) cnt += u;
    res.PB(cnt%2);
    return res;
}

std::vector<int> retrieve(std::vector<int> d) {
    int n = 0, dn = d.size();
    int x = 0, y = 0;
    if (dn < 255) n = 63;
    else n = 255;
	int cnt = 0;
    FOR(i,n,dn-1) {
        x += d[i]*(1<<(i-n));
		cnt += d[i];
    }
    if (cnt%2 == d[dn-1]) {
        FOR(i,0,n) {
			if (d[i] == 1) y ^= i+1;
		}
        x ^= y;
        if (x-1 >= 0) d[x-1] ^= 1;
    }
    return std::vector<int>(d.begin(),d.begin()+n);
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:28:16: warning: unused variable 'p' [-Wunused-variable]
   28 |     int k = 0, p = 0;
      |                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 640 KB Output is correct
2 Correct 3 ms 740 KB Output is correct
3 Correct 3 ms 652 KB Output is correct
4 Correct 3 ms 732 KB Output is correct
5 Correct 3 ms 732 KB Output is correct
6 Correct 3 ms 644 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 4 ms 644 KB Output is correct
9 Correct 3 ms 652 KB Output is correct
10 Correct 4 ms 728 KB Output is correct
11 Correct 3 ms 644 KB Output is correct
12 Correct 3 ms 732 KB Output is correct
13 Correct 3 ms 652 KB Output is correct
14 Correct 3 ms 644 KB Output is correct
15 Correct 1 ms 652 KB Output is correct
16 Correct 3 ms 732 KB Output is correct
17 Correct 3 ms 644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 2488 KB Output is correct
2 Correct 50 ms 2488 KB Output is correct
3 Correct 55 ms 2492 KB Output is correct
4 Correct 55 ms 2484 KB Output is correct
5 Correct 60 ms 2492 KB Output is correct
6 Correct 59 ms 2492 KB Output is correct
7 Correct 54 ms 2480 KB Output is correct
8 Correct 52 ms 2484 KB Output is correct
9 Correct 50 ms 2484 KB Output is correct
10 Correct 43 ms 2492 KB Output is correct
11 Correct 44 ms 2488 KB Output is correct
12 Correct 51 ms 2484 KB Output is correct
13 Correct 49 ms 2492 KB Output is correct
14 Correct 56 ms 2492 KB Output is correct
15 Correct 48 ms 2480 KB Output is correct
16 Correct 50 ms 2500 KB Output is correct
17 Correct 52 ms 2484 KB Output is correct
18 Correct 51 ms 2484 KB Output is correct
19 Correct 51 ms 2484 KB Output is correct