# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
575586 | 2022-06-11T05:48:38 Z | Arvin | Ancient Machine (JOI21_ancient_machine) | C++17 | 59 ms | 8592 KB |
#include "Anna.h" #include <bits/stdc++.h> using namespace std; #define ll long long namespace { int variable_example = 0; const int maxN = 1e5 + 5; } void Anna(int N, std::vector<char> S) { // 1 as store this first X or any Z after first Xa // 0 otherwise vector<int> v; ll pos = -1; bool fX = false; for(int x=0;x<N;x++){ if(S[x] == 'Z'){ if(fX && (x+1 == N || S[x+1] != 'Z')){ v.push_back(1); } else { v.push_back(0); } // Send(fX); } else if(S[x] == 'Y'){ // Send(0); v.push_back(0); } else if(S[x] == 'X'){ if(!fX){ v.push_back(1); // Send(1); fX = true; pos = x; } else { v.push_back(0); // Send(0); } } } // guaranteed bit 1 at most N/2 + 1 // alternating, only special case where first X and any Z are adjacent. // first 16 bits are location of first X // if not exist: ok delete all // else : // check first bit after loc // if 0 length is odd // - if one: // - - // - else: pos++; for(int y=0;y<17;y++){ if(pos&(1ll << y)){ Send(1); } else { Send(0); } } if(pos == 0){ return; } ll cnt[90]; ll sum = 2; ll table[90]; table[0] = 1; cnt[0] = 1; table[1] = 1; cnt[1] = 2; for(int x=2;x<88;x++){ table[x] = 0; for(int y=0;y<=x-2;y++){ table[x] += table[y]; } sum += table[x]; cnt[x] = sum; } // cout << "... " << pos << "\n"; while(pos < v.size()){ ll val = 0; for(int x=85;x>=0;x--){ if(pos+x < v.size() && v[pos+x] == 1){ // cout << "+ " << x << " " << val << "+" << cnt[x] << "\n"; val += cnt[x]; } } for(int y=0;y<60;y++){ if(val&(1ll << y)){ Send(1); } else { Send(0); } } pos += 86; } // Send(v[0]); // bool skip = false; // for(int x=0;x<N;x++){ // if(skip){ // skip = false; // continue; // } // if(v[x] == 0){ // if(x+1 == N || v[x+1] == 1){ // Send(0); // if(x+1 < N && v[x+1] == 1) Send(1); // else Send(0); // } else { // Send(1); // if(x+2 < N && v[x+2] == 1){ // Send(1); // } else { // Send(0); // } // skip = true; // } // } // } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 508 KB | Output is correct |
2 | Correct | 0 ms | 508 KB | Output is correct |
3 | Correct | 0 ms | 512 KB | Output is correct |
4 | Correct | 1 ms | 512 KB | Output is correct |
5 | Correct | 0 ms | 508 KB | Output is correct |
6 | Correct | 0 ms | 516 KB | Output is correct |
7 | Correct | 0 ms | 516 KB | Output is correct |
8 | Correct | 0 ms | 508 KB | Output is correct |
9 | Correct | 0 ms | 508 KB | Output is correct |
10 | Correct | 0 ms | 508 KB | Output is correct |
11 | Correct | 0 ms | 516 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 8476 KB | Output is correct |
2 | Correct | 52 ms | 8428 KB | Output is correct |
3 | Correct | 48 ms | 8520 KB | Output is correct |
4 | Correct | 54 ms | 8404 KB | Output is correct |
5 | Correct | 47 ms | 8356 KB | Output is correct |
6 | Correct | 48 ms | 8360 KB | Output is correct |
7 | Correct | 48 ms | 8572 KB | Output is correct |
8 | Correct | 48 ms | 8584 KB | Output is correct |
9 | Correct | 52 ms | 8440 KB | Output is correct |
10 | Correct | 49 ms | 8464 KB | Output is correct |
11 | Correct | 48 ms | 8560 KB | Output is correct |
12 | Correct | 48 ms | 8352 KB | Output is correct |
13 | Correct | 59 ms | 8480 KB | Output is correct |
14 | Correct | 56 ms | 8436 KB | Output is correct |
15 | Correct | 52 ms | 8416 KB | Output is correct |
16 | Correct | 53 ms | 8380 KB | Output is correct |
17 | Correct | 53 ms | 8500 KB | Output is correct |
18 | Correct | 44 ms | 6976 KB | Output is correct |
19 | Correct | 44 ms | 7060 KB | Output is correct |
20 | Correct | 48 ms | 8404 KB | Output is correct |
21 | Correct | 46 ms | 8440 KB | Output is correct |
22 | Correct | 53 ms | 8360 KB | Output is correct |
23 | Correct | 52 ms | 8540 KB | Output is correct |
24 | Correct | 47 ms | 8492 KB | Output is correct |
25 | Correct | 46 ms | 7132 KB | Output is correct |
26 | Correct | 53 ms | 8524 KB | Output is correct |
27 | Correct | 45 ms | 7184 KB | Output is correct |
28 | Correct | 53 ms | 8456 KB | Output is correct |
29 | Correct | 50 ms | 7000 KB | Output is correct |
30 | Correct | 45 ms | 7264 KB | Output is correct |
31 | Correct | 45 ms | 7084 KB | Output is correct |
32 | Correct | 48 ms | 8592 KB | Output is correct |
33 | Correct | 49 ms | 8492 KB | Output is correct |