Submission #1180466

#TimeUsernameProblemLanguageResultExecution timeMemory
1180466kigash메시지 (IOI24_message)C++20
0 / 100
0 ms840 KiB
#include "bits/stdc++.h"
#include "message.h"
using namespace std;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds; // order_of_key() skolko menshe, find_by_order() a[x]
// template<typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

using ll = long long;
using ld = long double;
#define int ll
#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

void freopen(string s) { freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); }
int binmul(int a, int b, int c) { int res = 0; while(b) { if(b & 1) (res += a) %= c; (a += a) %= c; b >>= 1; } return res; }
int binpow(int a, int b, int c) { int res = 1; while(b) { if(b & 1) (res *= a) %= c; (a *= a) %= c; b >>= 1; } return res; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll inf = 1e18+7, MX = LLONG_MAX, MN = LLONG_MIN;
const int mod = 1e9+7, N = 3e5+5;

void send_message(vector<bool> M, vector<bool> C) {
    for(int i = 0; i < sz(C); i++) {
        vector<bool> s(31, C[i]);
        send_packet(s);
    }
    vector<bool> s(31, 0);
    for(int i = 0, j = 0; i < sz(C); i++) {
        if(C[i]) continue;
        if(sz(M)&(1<<j)) s[i] = 1;
        j++;
    }
    send_packet(s);
    int i = 0;
    while(i < sz(M)) {
        vector<bool> s(31);
        for(int j = 0; j < sz(C) && i < sz(M); j++) {
            if(C[j]) continue;
            C[j] = M[i];
            i++;
        }
        send_packet(s);
    }
}

vector<bool> receive_message(vector<vector<bool>> R) {
    vector<bool> C;
    for(int i = 0; i < 31; i++) {
        int cnt = 0;
        for(int j = 0; j < 31; j++) {
            if(R[i][j]) cnt++;
        }
        if(cnt >= 16) C.pb(1);
        else C.pb(0);
    }
    int len = 0;
    for(int i = 0, j = 0; i < sz(C); i++) {
        if(C[i]) continue;
        if(R[31][i]) len += (1<<j);
        j++;
    }
    vector<bool> ans;
    for(int i = 32; i < sz(R); i++) {
        for(int j = 0; j < 31 && sz(ans) < len; j++) {
            if(C[j]) continue;
            ans.pb(R[i][j]);
        }
    }
    return ans;
}

Compilation message (stderr)

message.cpp: In function 'void freopen(std::string)':
message.cpp:24:33: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 | void freopen(string s) { freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); }
      |                          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
message.cpp:24:73: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 | void freopen(string s) { freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); }
      |                                                                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...