Submission #1309114

#TimeUsernameProblemLanguageResultExecution timeMemory
1309114duongquanghai08Ancient Machine (JOI21_ancient_machine)C++20
5 / 100
33 ms6436 KiB
#include "Anna.h" #include <bits/stdc++.h> using namespace std; const int N = 63; void Anna(int n, vector<char> S) { vector<long long> f(100, 0); vector<int> a(n + 5, 0); f[0] = 1, f[1] = 2; for(int i = 2; i <= 63; i++) { f[i] = f[i - 1] + f[i - 2]; // cout << f[i] << '\n'; } bool check = false; int pos = 0; for(int i = 0; i < n; i++) { char x = S[i]; if(x == 'X' && !check) { check = true; pos = i; a[i] = 1; continue; } if(!check) a[i] = 0; else { if(x == 'X' || x == 'Y') a[i] = 0; else a[i] = 1; } } if(a[pos] && a[pos + 1]) a[pos + 1] = 0; for(int i = pos + 2; i < n; i++) { if(a[i] && a[i - 1]) a[i - 1] = 0; } //for(int i = 0; i < n; i++) cout << a[i] << ' '; // cout << '\n'; for(int i = 0; i < n; i += 63) { long long sum = 0; for(int len = 0; i + len < n && len <= 62; len++) { if(a[i + len]) sum += f[len]; } for(int j = 0; j <= 43; j++) { if((sum >> j) & 1) Send(1); else Send(0); } } }
#include "Bruno.h" #include <bits/stdc++.h> using namespace std; void Bruno(int n, int L, vector<int> A) { vector<long long> f(100, 0); vector<int> a(n + 100, 0); f[0] = 1, f[1] = 2; for(int i = 2; i <= 63; i++) f[i] = f[i - 1] + f[i - 2]; int pre = 0; for(int i = 0; i < n; i += 63) { long long sum = 0; for(int j = pre; j <= pre + 43; j++) if(A[j]) sum |= (1LL << (j - pre)); pre += 44; for(int len = 62; len >= 0; len--) { if(sum >= f[len]) a[i + len] = 1, sum -= f[len]; } } //for(int i = 0; i < n; i++) cout << a[i] << ' '; //cout << '\n'; bool check = false; int pos = -1; stack<int> st; for(int i = 0; i < n; i++) { // cout << 1111 << " " << A[i] << ' '; if(a[i] == 1 && !check) { check = true; pos = i; continue; } if(!check) { Remove(i); continue; } if(a[i] == 1) { while(!st.empty()) Remove(st.top()), st.pop(); Remove(i); } else st.push(i); } while(!st.empty()) Remove(st.top()), st.pop(); if(pos != -1) Remove(pos); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...