QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#211251 | #5093. 会议 | hos_lyric# | 0 | 38ms | 4500kb | C++14 | 4.0kb | 2023-10-12 13:37:42 | 2024-07-04 02:19:17 |
Judging History
answer
#include "majority.h"
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
namespace {
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")
int Q = 0;
vector<D_t> X{D_t(-1)};
// (id, [same as path[i - 2]])
vector<pair<int, int>> path;
// same as path[$ - 1]
set<int> rems;
bool answer() {
if (path.size() >= 1) {
int i = (int)path.size() - 1;
for (; path[i].second; i -= 2) {}
if (i == 0 || (i == 1 && rems.size())) {
submit(X[path.back().first]);
return true;
}
return false;
} else {
return false;
}
}
} // namespace
bool insert(const D_t &x) {
++Q;
X.push_back(x);
if (path.size() >= 1) {
if (X[path.back().first] == X[Q]) {
int i = (int)path.size() - 1;
for (; path[i].second; i -= 2) {}
if (i == 0) {
rems.insert(Q);
} else {
path.emplace(path.begin() + (i - 1), Q, (i >= 3 && X[path[i - 3].first] == X[Q]) ? 1 : 0);
path[i].second = 0;
path[i + 1].second = 1;
}
} else {
path.emplace_back(Q, (path.size() >= 2 && X[path[path.size() - 2].first] == X[Q]) ? 1 : 0);
if (rems.size()) {
path.emplace_back(*rems.begin(), 1);
rems.erase(rems.begin());
}
}
} else {
path.emplace_back(Q, 0);
}
return answer();
}
bool erase(int id) {
// TODO
auto it = rems.find(id);
if (it != rems.end()) {
rems.erase(it);
} else {
int j;
for (j = 0; j < (int)path.size(); ++j) if (path[j].first == id) break;
assert(j < (int)path.size());
path.erase(path.begin() + j);
if (j < (int)path.size() && path[j].second) {
const int t = path[j].first;
path.erase(path.begin() + j);
if (j < (int)path.size()) {
path[j].second = (j - 2 >= 0 && X[path[j - 2].first] == X[path[j].first]) ? 1 : 0;
}
int i = j - 1;
for (; path[i].second; i -= 2) {}
if (i == 0) {
i = j - 1;
for (; i + 2 < (int)path.size() && path[i + 2].second; i += 2) {}
if (i == (int)path.size() - 1) {
rems.insert(t);
} else {
path.emplace(path.begin() + (i + 2), t, 1);
if (i + 3 < (int)path.size()) {
path[i + 3].second = 0;
}
if (i + 4 < (int)path.size()) {
path[i + 4].second = (X[t] == X[path[i + 4].first]) ? 1 : 0;
}
}
} else {
path.emplace(path.begin() + (i - 1), t, (i >= 3 && X[path[i - 3].first] == X[t]) ? 1 : 0);
path[i].second = 0;
path[i + 1].second = 1;
}
} else {
if (j < (int)path.size()) {
path[j].second = (j - 2 >= 0 && X[path[j - 2].first] == X[path[j].first]) ? 1 : 0;
}
if (j + 1 < (int)path.size()) {
path[j + 1].second = (j - 1 >= 0 && X[path[j - 1].first] == X[path[j + 1].first]) ? 1 : 0;
}
}
}
return answer();
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3744kb
input:
1 100 0 4 0 4 0 1 1 1 0 2 0 2 1 3 1 2 0 2 1 5 0 2 0 3 0 3 0 4 1 8 1 9 1 6 0 1 0 2 0 1 1 11 1 12 0 2 1 13 1 14 1 4 0 2 1 15 0 3 1 16 0 4 0 2 0 2 1 17 1 19 1 7 0 3 1 20 0 4 1 21 0 4 1 22 0 1 0 3 1 23 1 24 0 3 1 25 0 1 0 4 1 26 1 27 0 4 0 1 1 29 1 28 0 4 1 30 0 1 0 3 0 4 0 4 0 3 0 2 1 34 0 4 0 4 0 3 1 ...
output:
QOJ-SECURITYLIB-V23368-nhCapeXC2shGseuHTgYE-bt0m87qTfR8OPcSSLBkv 0 2 1 4 1 4 1 4 0 -1 0 -1 0 -1 1 2 1 2 1 2 0 -1 1 2 1 2 1 2 0 -1 1 2 1 2 1 2 0 -1 1 2 0 -1 1 2 0 -1 1 2 1 2 1 2 0 -1 1 2 0 -1 0 -1 0 -1 1 4 0 -1 1 2 1 2 1 2 0 -1 0 -1 0 -1 1 4 0 -1 1 4 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 1 4 0...
result:
wrong answer both questions wrong
Subtask #2:
score: 0
Wrong Answer
Test #72:
score: 0
Wrong Answer
time: 2ms
memory: 4132kb
input:
2 5000 0 2 0 1 0 3 1 3 0 4 1 4 0 3 1 5 0 1 0 2 1 7 1 1 0 2 0 3 0 3 1 9 1 8 1 10 0 1 1 11 0 2 0 4 1 12 0 4 0 4 0 3 1 14 1 15 0 1 1 13 0 3 0 3 1 2 0 4 0 3 1 21 0 1 1 22 1 20 1 6 1 16 1 19 0 3 1 23 0 4 0 1 0 1 1 25 1 18 1 17 0 4 0 4 0 1 0 4 0 2 1 31 1 28 1 27 0 4 1 32 1 29 1 26 0 4 1 33 0 2 0 3 1 35 1 ...
output:
QOJ-SECURITYLIB-V23368-nhCapeXC2shGseuHTgYE-bt0m87qTfR8OPcSSLBkv 0 2 1 2 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 1 1 0 -1 1 1 1 1 1 1 0 -1 0 -1 0 -1 1 1 1 1 1 1 1 1 1 1 0 -1 1 1 0 -1 1 4 0 -1 0 -1 0 -1 1 1 1 1 1 1 0 -1 1 3 0 -1 1 3 0 -1 0 -1 0 -1 1 3 1 3 1 3 0 -1 1 3 0 -1 0 -1 0 -1 1 1 0 -1 1 1 0 -1 1 4 ...
result:
wrong answer both questions wrong
Subtask #3:
score: 0
Wrong Answer
Test #143:
score: 0
Wrong Answer
time: 18ms
memory: 3960kb
input:
3 50000 0 2 0 1 0 1 1 1 0 4 1 2 0 1 1 4 0 3 1 6 0 4 1 7 0 1 0 4 1 3 1 8 0 3 0 1 0 2 0 3 1 10 1 13 0 3 0 2 0 1 0 2 1 14 1 17 0 4 0 1 1 18 1 15 1 16 0 4 0 1 1 20 1 21 1 19 1 11 1 5 0 1 0 4 1 23 1 9 0 1 1 24 0 3 0 1 1 25 1 26 0 3 0 3 1 27 1 28 0 1 1 29 0 4 0 4 0 1 1 31 1 30 0 1 1 33 1 32 0 4 0 4 1 34 1...
output:
QOJ-SECURITYLIB-V23368-nhCapeXC2shGseuHTgYE-bt0m87qTfR8OPcSSLBkv 0 2 1 2 0 -1 1 1 1 1 1 1 0 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 1 1 1 1 0 -1 0 -1 1 1 1 2 0 -1 0 -1 1 2 0 -1 0 -1 0 -1 0 -1 0 -1 1 1 0 -1 0 -1 0 -1 1 1 0 -1 0...
result:
wrong answer both questions wrong
Subtask #4:
score: 0
Wrong Answer
Test #214:
score: 0
Wrong Answer
time: 38ms
memory: 4500kb
input:
4 100000 0 3 0 3 0 3 0 4 0 2 1 4 0 2 0 2 0 3 0 2 0 1 0 2 0 3 0 1 1 7 1 5 1 12 0 2 0 2 1 1 1 10 0 2 1 14 0 3 1 17 0 2 1 8 0 1 0 1 0 4 1 20 1 11 1 6 0 1 1 9 1 21 1 19 1 18 1 22 1 3 1 15 1 16 0 1 0 2 0 2 1 23 0 2 0 2 1 26 0 4 0 4 1 29 1 25 0 4 0 1 0 3 0 2 1 31 1 32 1 24 0 4 1 34 1 27 0 4 0 2 0 1 1 35 0...
output:
QOJ-SECURITYLIB-V23368-nhCapeXC2shGseuHTgYE-bt0m87qTfR8OPcSSLBkv 0 2 1 3 1 3 1 3 1 3 1 3 1 3 1 3 0 -1 1 3 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 1 2 1 2 0 -1 0 -1 1 1 0 -1 1 2 0 -1 1 1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 1 1 0 -1 0 -1 0 -1 1 2 1 2 1 2 0 -...
result:
wrong answer both questions wrong