제출 #935643

#제출 시각아이디문제언어결과실행 시간메모리
935643Boycl07Ancient Machine (JOI21_ancient_machine)C++17
100 / 100
46 ms8884 KiB
#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) 메시지

Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:61:9: warning: unused variable 'flag' [-Wunused-variable]
   61 |     int flag = 0;
      |         ^~~~

Bruno.cpp: In function 'void decode(std::vector<int>&)':
Bruno.cpp:45:9: warning: unused variable 'j' [-Wunused-variable]
   45 |     int j = 0, pos = 0;
      |         ^
Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:78:9: warning: unused variable 'pos' [-Wunused-variable]
   78 |     int pos = 0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...