Submission #372412

#TimeUsernameProblemLanguageResultExecution timeMemory
372412Killer2501Painting Squares (IOI20_squares)C++14
0 / 100
3 ms1864 KiB
#include <bits/stdc++.h>
#define pb push_back
#define vii vector<int>
#define task "ABC"
#define pll pair<ll, ll>
#define pii pair< pll, ll >
#define fi first
#define se second

using namespace std;
using ll = int;
using ull = unsigned long long;
const int N = 3e5+5;
const ll mod = 1e9+7;
const ll base1 = 1313;
const ll base2 = 3113;
ll m, n, k, t, T, ans, a[N], b[N],   tong, cur;
string s;
vector<ll> kq;
ll pw(ll k, ll n)
{
    ll total = 1;
    for(; n; n >>= 1)
    {
        if(n & 1)total = total * k % mod;
        k = k * k % mod;
    }
    return total;
}

vector<ll> paint(int n)
{
    //cin >> n;
    ll lf = 1, rt = 10, mid;
    while(lf <= rt)
    {
        mid = (lf + rt) / 2;
        tong = (1<<mid) + mid-1;
        if(tong < n)lf = mid + 1;
        else rt  = mid - 1;
    }
    kq.clear();
    k = lf;
    fill_n(b, (1<<k)+4, 0);
    for(int i = 1; i <= min(k, n);  i++)
    {
        kq.pb(1);
        a[k] = a[k] * 2 + 1;
    }
    tong = a[k];
    b[tong] = 1;
    for(int i = k+1; i <= n; i ++)
    {
        t = a[i-1] * 2;
        t &= tong;
        if(b[t] == 0)kq.pb(0);
        else
        {
            t += 1;
            kq.pb(1);
        }
        a[i] = t;
        b[t] = 1;
    }
    kq.pb(k);
    return kq;
}
int find_location(int n, vector<int> c)
{
    k = c.size();
    tong = 0;
    ans = 0;
    for(int i = 0; i < k; i ++)
    {
        if(c[i] == -1)
        {
            return n-i;
        }
        if(c[i])ans = ans * 2 + 1;
        else ans = ans * 2;
        tong = tong * 2 + 1;
    }
    fill_n(b, (1<<k)+4, 0);
    a[k] = tong;
    if(tong == ans)
    {
        return 1;
    }
    for(int i = k+1; i <= n; i ++)
    {
        t = a[i-1] * 2;
        t &= tong;
        if(b[t])++t;
        a[i] = t;
        b[t] = 1;
        if(a[i] == ans)
        {
            return i-k+1;
        }
    }

}

Compilation message (stderr)

squares.cpp: In function 'int find_location(int, std::vector<int>)':
squares.cpp:102:1: warning: control reaches end of non-void function [-Wreturn-type]
  102 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...