제출 #1071265

#제출 시각아이디문제언어결과실행 시간메모리
1071265PlurmAncient Machine (JOI21_ancient_machine)C++17
30 / 100
100 ms16020 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 { int FT[100005]; void add(int idx, int amt) { idx++; while (idx < 100005) { FT[idx] += amt; idx += idx & -idx; } } int sum(int idx) { idx++; int ret = 0; while (idx > 0) { ret += FT[idx]; idx -= idx & -idx; } return ret; } } // namespace void Bruno(int N, int L, std::vector<int> A) { set<int> active; memset(FT, 0, sizeof(FT)); 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; priority_queue<pair<int, int>> pq; vector<int> prefX(N, -1); for (int i = 0; i < N; i++) { active.insert(i); add(i, 1); 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]; } for (int i = 0; i < N; i++) { if (target[i] == 'Y' && prefX[i] != -1 && suffZ[i] != N) { int c = suffZ[i] - prefX[i] - 2; pq.push({-c, i}); } } vector<int> ord; while (!pq.empty()) { auto ok = pq.top(); pq.pop(); if (target[ok.second] == '\0') continue; if (sum(suffZ[ok.second] - 1) - sum(prefX[ok.second]) - 1 != -ok.first) { pq.push({-(sum(suffZ[ok.second] - 1) - sum(prefX[ok.second]) - 1), ok.second}); continue; } auto it = active.upper_bound(prefX[ok.second]); while (it != active.end() && *it < suffZ[ok.second]) { int j = *it; if (j == ok.second) { ++it; continue; } target[j] = '\0'; add(j, -1); ord.push_back(j); it = active.erase(it); } target[ok.second] = '\0'; add(ok.second, -1); ord.push_back(ok.second); active.erase(ok.second); } 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:37:10: warning: unused variable 'done' [-Wunused-variable]
   37 |     bool done = false;
      |          ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...