제출 #1180479

#제출 시각아이디문제언어결과실행 시간메모리
1180479kigash메시지 (IOI24_message)C++20
30.33 / 100
528 ms860 KiB
#include "message.h"
#include "bits/stdc++.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;
// vector<vector<bool>> g;

// void send_packet(vector<bool> s) {
//     g.pb(s);
// }

void send_message(vector<bool> M, vector<bool> C) {
    for(int i = 0; i < 30; 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++;
    }
    for(int i = 30; i >= 0; i--) {
        if(!C[i]) {
            s[i] = M.back();
            break;
        }
    }
    send_packet(s);
    int pos = sz(M)-1;
    for(int i = sz(M)-2; i >= 0; i--) {
        if(M[i] != M.back()) break;
        pos = i;
    }
    int i = 0;
    while(i < pos) {
        vector<bool> s(31);
        for(int j = 0; j < sz(C) && i < sz(M); j++) {
            if(C[j]) continue;
            s[j] = M[i];
            i++;
        }
        send_packet(s);
    }
}

vector<bool> receive_message(vector<vector<bool>> R) {
    // vector<vector<bool>> R = g;
    // for(auto cur: R) {
    //     for(int i = 0; i < sz(cur); i++) cout << cur[i] << " ";
    //     cout << "\n";
    // }
    vector<bool> C;
    int zero = 0;
    for(int i = 0; i < 30; 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), zero++;
    }
    if(zero == 16) C.pb(1);
    else C.pb(0);
    int len = 0, last = 0;
    for(int i = 0, j = 0; i < sz(C); i++) {
        if(C[i]) continue;
        if(j > 10) last = R[30][i];
        if(j <= 10 && R[30][i]) len += (1<<j);
        j++;
    }
    vector<bool> ans;
    for(int i = 31; i < sz(R); i++) {
        for(int j = 0; j < 31 && sz(ans) < len; j++) {
            if(C[j]) continue;
            ans.pb(R[i][j]);
        }
    }
    while(sz(ans) < len) ans.pb(last);
    return ans;
}

// signed main() {
//     ios_base::sync_with_stdio(false);
//     cin.tie(NULL);
//     vector<bool> C;
//     for(int i = 0; i < 31; i++) {
//         int x;
//         cin >> x;
//         C.pb(x);
//     }
//     send_message({0, 1, 1, 0}, C);
//     vector<bool> ans = receive_message();
//     for(int i = 0; i < sz(ans); i++) cout << ans[i] << " ";
//     cout << "\n";
//     return 0;
// }

컴파일 시 표준 에러 (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...