This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "circuit.h"
#include <vector>
using namespace std;
int ma;
using ll = long long;
constexpr ll mod = 1000002022;
struct SVal {
ll pos, fpos, tPos;
};
SVal comb(SVal l, SVal r) {
return SVal{((l.tPos*r.tPos)%mod - ((l.tPos - l.pos)*(r.tPos - r.pos))%mod + mod + (l.pos*r.pos)%mod)%mod, ((l.tPos*r.tPos)%mod - ((l.tPos - l.fpos)*(r.tPos - r.fpos))%mod + mod + (l.fpos*r.fpos)%mod)%mod, (l.tPos*r.tPos)%mod};
}
struct SegTe {
vector<SVal> a;
vector<bool> lazy;
void push(int i) {
if (lazy[i]) {
swap(a[i].pos, a[i].fpos);
if (2*i + 2 < a.size()) {
lazy[2*i + 1] = !lazy[2*i + 1];
lazy[2*i + 2] = !lazy[2*i + 2];
}
lazy[i] = false;
}
}
SVal toggle(int l, int r, int i, int lq, int rq) {
push(i);
if (rq <= l || r <= lq) return a[i];
if (lq <= l && r <= rq) {
lazy[i] = true;
push(i);
return a[i];
}
int m = (l + r)/2;
}
};
SegTe se;
void init(int N, int M, std::vector<int> P, std::vector<int> A) {
ma = N;
se = SegTe{vector<SVal>(2*M, SVal{0, 1, 1}), vector<bool>(2*M, false)};
for (int i = 0; i < M; ++i) {
se.toggle(0, M, 0, i, i + 1);
}
}
int count_ways(int L, int R) {
L -= ma;
R -= ma;
return se.toggle(0, ma + 1, 0, L, R + 1).pos;
}
Compilation message (stderr)
circuit.cpp: In member function 'void SegTe::push(int)':
circuit.cpp:27:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<SVal>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | if (2*i + 2 < a.size()) {
| ~~~~~~~~^~~~~~~~~~
circuit.cpp: In member function 'SVal SegTe::toggle(int, int, int, int, int)':
circuit.cpp:43:7: warning: unused variable 'm' [-Wunused-variable]
43 | int m = (l + r)/2;
| ^
circuit.cpp:43:7: warning: control reaches end of non-void function [-Wreturn-type]
43 | int m = (l + r)/2;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |