# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
935643 | Boycl07 | Ancient Machine (JOI21_ancient_machine) | C++17 | 46 ms | 8884 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define forn(i, l, r) for(int i = l; i <= r; ++i)
#define ford(i, r, l) for(int i = r; i >= l; --i)
#define FOR(i, n) for(int i = 0; i < n; ++i)
#define FORD(i, n) for(int i = n - 1; i >= 0; --i)
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define endl "\n"
#define task "skycrapers"
#define sz(a) int(a.size())
#define C(x, y) make_pair(x, y)
#define all(a) (a).begin(), (a).end()
#define bit(i, mask) (mask >> i & 1)
void Anna(int N, std::vector<char> S);
void Send(int a);
const int Lim = 83;
const int LOG = 57;
ll f[Lim];
void precalc()
{
f[0] = 1;
f[1] = 2;
for(int i = 2; i < Lim; ++i)
f[i] = f[i - 1] + f[i - 2];
}
void Send_num(ll x)
{
for(int i = 0; i <= LOG; ++i)
if(x >> i & 1) Send(1);
else Send(0);
}
void Anna(int n, vector<char> S)
{
precalc();
vector<int> res;
int idx = 0;
while(idx < n && S[idx] != 'X') res.pb(0), ++idx;
int pos = 0;
if(idx != n)
{
pos = idx;
res.pb(0), ++idx;
}
int flag = 0;
while(idx < n)
{
if(S[idx] != 'Z') res.pb(0), ++idx;
else
{
int j = idx;
while(j < n && S[j] == 'Z') ++j;
--j;
forn(k, idx, j - 1) res.pb(0);
res.pb(1);
idx = j + 1;
}
}
//for(int x : res) cout << x; cout << endl;
for(int i = 0; i < n; i += Lim)
{
ll cur = 0;
forn(j, i, i + Lim)
if(j < n) if(res[j]) cur += f[j - i];
Send_num(cur);
}
//cout << "FIRST_X: " << pos << endl;
for(int i = 0; i <= 16; ++i) if(pos >> i & 1) Send(1);
else Send(0);
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define forn(i, l, r) for(int i = l; i <= r; ++i)
#define ford(i, r, l) for(int i = r; i >= l; --i)
#define FOR(i, n) for(int i = 0; i < n; ++i)
#define FORD(i, n) for(int i = n - 1; i >= 0; --i)
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define endl "\n"
#define task "skycrapers"
#define sz(a) int(a.size())
#define C(x, y) make_pair(x, y)
#define all(a) (a).begin(), (a).end()
#define bit(i, mask) (mask >> i & 1)
void Bruno(int N, int L, std::vector<int> A);
void Remove(int d);
const int Lim_ = 83;
ll f_[Lim_];
void precalc_()
{
f_[0] = 1;
f_[1] = 2;
for(int i = 2; i < Lim_; ++i)
f_[i] = f_[i - 1] + f_[i - 2];
}
void decode(vector<int> &A)
{
vector<int> res;
int j = 0, pos = 0;
for(int i = 0; i < sz(A); i += 58)
{
if(i + 57 < sz(A))
{
ll cur = 0;
forn(j, 0, 57)
if(A[i + j] == 1)
cur |= 1ll << j;
vector<int> tmp;
ford(j, 82, 0)
if(cur >= f_[j]) tmp.pb(1), cur -= f_[j];
else tmp.pb(0);
reverse(all(tmp));
for(int x : tmp) res.pb(x);
}
else
{
forn(j, 0, 16)
if(A[i + j] == 1)
pos |= 1 << j;
}
}
A = move(res);
A[pos] = 1;
}
void Bruno(int n, int Len, vector<int> A)
{
precalc_();
int pos = 0;
decode(A); while(sz(A) > n) A.pop_back();
int first = 0;
while(first < n && A[first] != 1)
Remove(first++);
if(first == n) return;
for(int i = first + 1; i < n; ++i)
{
int j = i;
while(j < n && A[j] != 1) ++j;
ford(k, j - 1, i) Remove(k);
if(j != n) Remove(j);
i = j;
}
Remove(first);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |