제출 #752180

#제출 시각아이디문제언어결과실행 시간메모리
752180Sam_a17Ancient Machine (JOI21_ancient_machine)C++17
0 / 100
99 ms10876 KiB
#include <bits/stdc++.h> #include "Anna.h" using namespace std; void Send(int a); void Anna(int N, std::vector<char> S) { Send(0); for(int i = 0; i < N; i++) { if(S[i] == 'X') { Send(0); } else if(S[i] == 'Y') { Send(1); Send(0); } else { Send(1); Send(1); Send(0); } } }
#include <bits/stdc++.h> #include "Bruno.h" using namespace std; void Remove(int d); void Bruno(int N, int L, std::vector<int> A) { vector<int> a; for(int i = 0; i < L - 1; i++) { assert(A[i] == 0); int j = i + 1, cnt = 0; while(j < L && A[j] == 1) { j++, cnt++; } if(cnt == 0) { a.push_back(0); } else if(cnt == 1) { a.push_back(1); } else { a.push_back(2); } i = j - 1; } set<int> st[3]; auto dll = [&](int l, int r)-> void { for(int i = 0; i < 3; i++) { auto it = st[i].lower_bound(l); vector<int> to_del; while(it != st[i].end() && *it < r) { to_del.push_back(*it); it = next(it); } for(auto j: to_del) { Remove(j); st[i].erase(j); } } }; for (int i = 0; i < N; i++) { int ok = 0; if(a[i] == 2) { if(!st[1].empty() && !st[0].empty()) { auto itr = *st[1].rbegin(); auto itl = *st[0].begin(); if(itl < itr) { dll(itr + 1, i); itl = *st[0].rbegin(); dll(itl + 1, itr); // st[1].erase(prev(st[1].end())); Remove(itr); ok = 1; } } } st[a[i]].insert(i); } for(int i = 0; i < 3; i++) { for(auto j: st[i]) { Remove(j); } } }

컴파일 시 표준 에러 (stderr) 메시지

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