#include "pyramids.h"
#include <vector>
using namespace std;
vector<int> prefixA, prefixB;
vector<int> remainderA, remainderB;
void init(vector<int> A, vector<int> B) {
int N = A.size();
prefixA.resize(N + 1, 0);
prefixB.resize(N + 1, 0);
remainderA.resize(N, 0);
remainderB.resize(N, 0);
for (int i = 0; i < N; ++i) {
prefixA[i + 1] = prefixA[i] + A[i];
prefixB[i + 1] = prefixB[i] + B[i];
}
for (int i = 1; i < N; ++i) {
remainderA[i] = (A[i] - A[i - 1] + 10) % 10;
remainderB[i] = (B[i] - B[i - 1] + 10) % 10;
}
}
bool can_transform(int L, int R, int X, int Y) {
if (prefixA[R + 1] - prefixA[L] != prefixB[Y + 1] - prefixB[X]) {
return false;
}
for (int i = L + 1, j = X + 1; i <= R; ++i, ++j) {
if (remainderA[i] != remainderB[j]) {
return false;
}
}
return true;
}
# | 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... |