Submission #592550

#TimeUsernameProblemLanguageResultExecution timeMemory
592550cheissmartAncient Machine (JOI21_ancient_machine)C++17
100 / 100
66 ms8060 KiB
#include "Anna.h" #include <vector> #include <bits/stdc++.h> #define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0); #define F first #define S second #define V vector #define PB push_back #define EB emplace_back #define MP make_pair #define SZ(v) int((v).size()) #define ALL(v) (v).begin(), (v).end() using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef V<int> vi; namespace { string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m"; void DBG() { cerr << "]" << _reset << endl; } template<class H, class...T> void DBG(H h, T ...t) { cerr << to_string(h); if(sizeof ...(t)) cerr << ", "; DBG(t...); } #define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__) const int INF = 1e9 + 7; ll fib[70]; } void Anna(int n, V<char> s) { int pos = n - 1; for(int i = 0; i < n; i++) if(s[i] == 'X') { pos = i; break; } for(int i = 0; i < 17; i++) Send(pos >> i & 1); V<bool> he(n); for(int i = pos + 1; i < n; i++) if(s[i] == 'Z' && (i + 1 >= n || s[i + 1] != 'Z')) he[i] = true; fib[0] = 1, fib[1] = 2; for(int i = 2; i < 70; i++) fib[i] = fib[i - 1] + fib[i - 2]; for(int i = 0; i < n; i += 63) { ll tt = 0; for(int j = i; j < n && j < i + 63; j++) tt += he[j] * fib[j - i]; assert(tt < (1LL << 44)); for(int j = 0; j < 44; j++) Send(tt >> j & 1); } }
#include "Bruno.h" #include <vector> #include <bits/stdc++.h> #define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0); #define F first #define S second #define V vector #define PB push_back #define EB emplace_back #define MP make_pair #define SZ(v) int((v).size()) #define ALL(v) (v).begin(), (v).end() using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef V<int> vi; namespace { string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m"; void DBG() { cerr << "]" << _reset << endl; } template<class H, class...T> void DBG(H h, T ...t) { cerr << to_string(h); if(sizeof ...(t)) cerr << ", "; DBG(t...); } #ifdef CHEISSMART #define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__) #else #define debug(...) #endif const int INF = 1e9 + 7; ll fib[100]; } void Bruno(int n, int l, vi a) { int pos = 0; for(int i = 0; i < 17; i++) pos |= a[i] << i; int sz = 17; vi zs; V<bool> be(n); fib[0] = 1, fib[1] = 2; for(int i = 2; i < 70; i++) fib[i] = fib[i - 1] + fib[i - 2]; for(int i = 0; i < n; i += 63) { ll tt = 0; for(int j = 0; j < 44; j++) tt += a[sz++] * (1LL << j); for(int j = 62; j >= 0; j--) { if(tt >= fib[j]) { be[i + j] = true; tt -= fib[j]; } } assert(tt == 0); } for(int i = 0; i < n; i++) if(be[i]) { zs.PB(i); } vi aux; for(int i = 0; i <= pos; i++) aux.PB(i); reverse(ALL(zs)); for(int i = pos + 1; i < n; i++) { if(SZ(zs) && zs.back() == i) { zs.pop_back(); while(aux.back() != pos) { Remove(aux.back()); aux.pop_back(); } Remove(i); } else { aux.PB(i); } } for(int i:aux) Remove(i); }

Compilation message (stderr)

Anna.cpp:22:6: warning: 'void {anonymous}::DBG()' defined but not used [-Wunused-function]
   22 | void DBG() { cerr << "]" << _reset << endl; }
      |      ^~~

Bruno.cpp:22:6: warning: 'void {anonymous}::DBG()' defined but not used [-Wunused-function]
   22 | void DBG() { cerr << "]" << _reset << endl; }
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...