제출 #1071219

#제출 시각아이디문제언어결과실행 시간메모리
1071219PlurmAncient Machine (JOI21_ancient_machine)C++17
5 / 100
2012 ms4908 KiB
#include "Anna.h" #include <vector> namespace { int variable_example = 0; } void Anna(int N, std::vector<char> S) { 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); } } }
#include "Bruno.h" #include <bits/stdc++.h> using namespace std; namespace { void resolve(vector<int> &ord, vector<vector<int>> &dp, vector<vector<int>> &par, int l, int r) { if (l > r) return; if (l == r) { ord.push_back(l); return; } if (par[l][r] >= 0) { resolve(ord, dp, par, l, par[l][r]); resolve(ord, dp, par, par[l][r] + 1, r); } else { resolve(ord, dp, par, l, ~par[l][r] - 1); if (find(ord.begin(), ord.end(), l) != ord.end()) ord.erase(find(ord.begin(), ord.end(), l)); resolve(ord, dp, par, ~par[l][r] + 1, r); if (find(ord.begin(), ord.end(), r) != ord.end()) ord.erase(find(ord.begin(), ord.end(), r)); ord.push_back(~par[l][r]); ord.push_back(l); ord.push_back(r); } } } // namespace void Bruno(int N, int L, std::vector<int> A) { string target; int ptr = 0; while (ptr < L) { if (A[ptr++] == 0) target.push_back('X'); else if (A[ptr++] == 0) target.push_back('Y'); else target.push_back('Z'); } bool done = false; vector<int> ord; int chosen = -1; do { vector<int> prefX(N, -1); for (int i = 0; i < N; i++) { if (target[i] == 'X') prefX[i] = i; else prefX[i] = i ? prefX[i - 1] : -1; } vector<int> suffZ(N, N); for (int i = N - 1; i >= 0; i--) { if (target[i] == 'Z') suffZ[i] = i; else suffZ[i] = i == N - 1 ? N : suffZ[i + 1]; } int mn = 1e9; chosen = -1; for (int i = 0; i < N; i++) { if (target[i] == 'Y' && prefX[i] != -1 && suffZ[i] != N) { int c = 0; for (int j = prefX[i] + 1; j <= suffZ[i] - 1; j++) { if (j == i) continue; if (target[j] != '\0') c++; } if (c < mn) { mn = c; chosen = i; } } } if (chosen != -1) { for (int j = prefX[chosen] + 1; j <= suffZ[chosen] - 1; j++) { if (j == chosen) continue; if (target[j] != '\0') { ord.push_back(j); target[j] = '\0'; } } ord.push_back(chosen); target[chosen] = '\0'; } } while (chosen != -1); for (int i = 0; i < N; i++) { if (target[i] != '\0') ord.push_back(i); } for (int x : ord) Remove(x); }

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

Anna.cpp:6:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    6 | int variable_example = 0;
      |     ^~~~~~~~~~~~~~~~

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:41:10: warning: unused variable 'done' [-Wunused-variable]
   41 |     bool done = false;
      |          ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...