Skip to content

Commit

Permalink
20240603 Equinox's submission (Yawn-Sean#3164)
Browse files Browse the repository at this point in the history
* Add files via upload

* Add files via upload

* Add files via upload

* Add files via upload

* Equinox's submission for cf1209c

* Equinox's submission for cf1525e

* Equinox's submission for cf567e

* Equinox's submission for cf1267j

* Equinox.submission for cf1270d

* Equinox's submission for cf1175c

* Equinox's submission for cf1575l

* Equinox's submission for cf989c

* Equinox's submission for cf1569d

* Equinox's submission for cf1129a2

* Equinox's submission for cf1644e

* cf1102e

* cf721d

* cf1019q

* Rename cf1019q_Equinox.cpp to cf1019a_Equinox.cpp

* cf720a

* cf1954d

* cf1954d

* cf869c

* cf1168b

* cf

* cf1217c

* cf1083b

* cf1083b

* cf
  • Loading branch information
58164 authored Jun 3, 2024
1 parent c887239 commit 131e3c2
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
42 changes: 42 additions & 0 deletions daily_problems/2024/06/0603/personal_submission/cf802b_Equinox.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <bits/stdc++.h>
using PII = std::pair<int, int>;
using i64 = long long;

const int inf = 1e9;


void solve() {
int N, K, res = 0;
std::cin >> N >> K;
std::vector<int> a(N);
std::map<int, std::vector<int>> pos;
std::unordered_set<int> buf;
std::priority_queue<PII> pq;

for (int i = 0; i < N; i ++ ) std::cin >> a[i];
for (int i = N - 1; ~i; i -- ) pos[a[i]].push_back(i);

for (int i = 0; i < N; i ++ ) {
pos[a[i]].pop_back();
if (buf.count(a[i])) {
if (pos[a[i]].size()) pq.emplace(pos[a[i]].back(), a[i]);
else buf.erase(a[i]);
continue;
}
while (pq.size() && !pos[pq.top().second].size()) pq.pop();
if (buf.size() == K) buf.erase(pq.top().second), pq.pop();
if (pos[a[i]].size()) buf.insert(a[i]), pq.emplace(pos[a[i]].back(), a[i]);
res ++;
}
std::cout << res;
}


int main () {
std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);
int _ = 1;
// std::cin >> _;
while (_ --)
solve();
return 0;
}
37 changes: 37 additions & 0 deletions daily_problems/2024/06/0603/personal_submission/cf862c_Equinox.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <bits/stdc++.h>
using PII = std::pair<int, int>;
using i64 = long long;

const int inf = 1e9;


void solve() {
int N, x;
std::cin >> N >> x;
if (N == 1) {
std::cout << "YES\n" << x;
return;
}
else if(N == 2) {
if (x) {
std::cout << "YES\n" << 0 << ' ' << x;
return;
}
std::cout << "NO";
return;
}
std::cout << "YES\n";
int pre = 0, o = 1 << 17, w = 1 << 18;
for (int i = 1; i <= N - 3; i ++ ) std::cout << i << ' ', pre ^= i;
std::cout << (o ^ pre) << ' ' << (w ^ o) << ' ' << (x ^ w);
}


int main () {
std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);
int _ = 1;
// std::cin >> _;
while (_ --)
solve();
return 0;
}

0 comments on commit 131e3c2

Please sign in to comment.