Submission #996642

#TimeUsernameProblemLanguageResultExecution timeMemory
996642hotboy2703Ancient Machine (JOI21_ancient_machine)C++17
70 / 100
47 ms10796 KiB
#include "Anna.h" #include<bits/stdc++.h> using ll = int; using namespace std; #define pll pair <ll,ll> #define fi first #define se second #define MP make_pair #define sz(a) (ll((a).size())) #define BIT(mask,i) (((mask) >> (i))&1) #define MASK(i) (1LL << (i)) namespace A{ struct pt{ ll type,l,r; }; } void Anna(int N, std::vector<char> S) { using namespace A; vector <ll> a; for (ll i = 0;i < N;i ++){ a.push_back(S[i]-'X'); } // for (auto x:a)cout<<x<<' '; // cout<<'\n'; vector <ll> res(N); vector <pt> nw; for (ll i = 0;i < N;i ++){ ll j = i; while (j + 1 < N && a[j+1] == a[i])j++; nw.push_back({a[i],i,j}); i = j; } while (!nw.empty() && nw.back().type != 2){ nw.pop_back(); } ll last0 = -1; for (ll i = 0;i < sz(nw);i ++){ if (last0 == -1){ if (nw[i].type == 0){res[nw[i].r] = 1;last0 = i;} } else{ ll j = i; while (nw[j].type != 2)j++; bool ok = 0; for (ll k = j-1;k >= i;k --){ if (nw[k].type==1)ok = 1; } res[nw[j].r] = 1; i = j; } } // for (auto x:res)cout<<x<<' '; // cout<<'\n'; for (auto x:res)Send(x); }
#include "Bruno.h" #include<bits/stdc++.h> using ll = int; using namespace std; #define pll pair <ll,ll> #define fi first #define se second #define MP make_pair #define sz(a) (ll((a).size())) #define BIT(mask,i) (((mask) >> (i))&1) #define MASK(i) (1LL << (i)) namespace B{ } // namespace void Bruno(int N, int L, std::vector<int> A) { using namespace B; vector <ll> a = A; vector <bool> del(N); ll last = -1; ll first = -1; for (ll i = 0;i < N;i ++){ if (A[i]){ if (first==-1)first = A[i]; else{ for (ll j = i - 1;j > last;j --){del[j] = 1;Remove(j);} del[i] = 1;Remove(i); } last = i; } } for (ll i = 0;i < N;i ++){ if (!del[i]){ Remove(i); } } }

Compilation message (stderr)

Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:47:18: warning: variable 'ok' set but not used [-Wunused-but-set-variable]
   47 |             bool ok = 0;
      |                  ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...