Submission #440962

# Submission time Handle Problem Language Result Execution time Memory
440962 2021-07-03T17:50:09 Z SorahISA Painting Squares (IOI20_squares) C++17
86.25 / 100
207 ms 576 KB
#include "squares.h"
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>;
template<typename T>
using Prior = std::priority_queue<T>;
template<typename T>
using prior = std::priority_queue<T, vector<T>, greater<T>>;

#define X first
#define Y second
#define eb emplace_back
#define pb pop_back
#define pf pop_front
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

string overall_label = "0100000010011101011010100101001010010110100101010000101101111100110001010101010011001100111001111001000100001010001000000011111101000110111110100111001100010010110100100010011011110101100101110001000100101110010011011001001010110010000011111010001111010100110010111001010110001110100110110111000110110100111001010010110011011010100111100100011000001101000011011000101110000011100101100001000101010010101101100101010010011110101111001000101111000111100110011111000110111011011010110111000000110110000101000001000000001001110110000110010110001011101100100101110011011110011010100011110100101111010111110101011001100101100011000111011100111101111110000001101000111001001001011101001111101101011111010111000110011001110100010010111110110101100110011111111111101100110000111100010110101111010111001110001110010111110100100110110111011011001001001000111100000111101100110110111100100100110000000011011011111011101001010111011001010101000001110100000000010101100111100000101010010011011100011111011100100011";
int overall_K = 15;

vector<int> paint(int N) {
    vector<int> label(N, 1);
    for (int i = 0; i < N; ++i) label[i] = overall_label[i] ^ '0';
    
    /*
    while (overall_K > 14) {
        for (auto &x : label) x = rng() & 1;
        int K = 10;
        while (true) {
            set<int64_t> app;
            for (int i = 0; i+K <= N; ++i) {
                int64_t val = 0;
                for (int j = 0; j < K; ++j) val = 2*val + label[i+j];
                app.insert(val);
            }
            if (app.size() == N - K + 1) break;
            ++K;
        }
        // for (auto x : label) cout << x;
        cout << K << " ";
        if (K < overall_K) {
            overall_K = K;
            for (int i = 0; i < N; ++i) overall_label[i] = char(label[i] ^ '0');
        }
    }
    cout << "\n" << overall_label << "\n" << overall_K << "\n";
    */
    
    label.eb(overall_K);
    return label;
}

int find_location(int N, vector<int> C) {
    string C_str;
    int ans = N;
    for (auto x : C) {
        if (x == -1) return ans;
        C_str += to_string(x), --ans;
    }
    for (int i = 0; i+overall_K <= N; ++i) {
        if (C_str == overall_label.substr(i, overall_K)) return i;
    }
    return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 122 ms 400 KB Output is correct
2 Correct 190 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 127 ms 460 KB Output is correct
2 Correct 207 ms 576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 163 ms 460 KB Output is correct
2 Correct 176 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 125 ms 468 KB Partially correct
2 Partially correct 191 ms 468 KB Partially correct