错误如题,代码如下:
// basic/functional headers
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
// debug headers
#include <stdexcept>
// data structure headers
#include <array>
// macros
#define INT_INF 2147483648
#define N_INT_INF -2147483649
// namespaces
using namespace std;
// aliases
using lld = long long int;
using ulld = unsigned long long int;
struct block {
lld color = -1, num = -1, id = -1;
};
array<block, 100100> PaperTape;
bool cmp(const block a, const block b);
// x+z==2y -> x,z:odd / x,z:even
// Cx==Cz;
// Score=(x+z)*(Nx+Nz);
int main() {
lld Blocks, ColorTypes, Score = 0;
scanf("%lld %lld", &Blocks, &ColorTypes);
for (lld i = 1; i <= Blocks; ++i) {
scanf("%lld", &PaperTape.at(i).num);
PaperTape.at(i).id = i;
}
for (lld i = 1; i <= Blocks; ++i) {
scanf("%lld", &PaperTape.at(i).color);
}
sort(PaperTape.begin() + 1, PaperTape.begin() + Blocks + 1, cmp);
for (lld i = 1; i <= Blocks - 1; ++i) {
for (lld j = i + 1; j <= Blocks; ++j) {
if (PaperTape.at(i).color != PaperTape.at(j).color) {
// printf("Break by different color\n");
break;
} else if (PaperTape.at(i).id % 2 != PaperTape.at(j).id % 2) {
// printf("Break by non odd odd or even even\n");
break;
} else {
Score += (PaperTape.at(i).id + PaperTape.at(j).id) *
(PaperTape.at(i).num + PaperTape.at(j).num);
Score %= 10007;
}
// printf("Score:%lld\n", Score);
}
}
printf("%lld", Score);
return 0;
}
bool cmp(const block a, const block b) {
if (a.color == b.color) {
if (a.id % 2 == b.id % 2) {
return a.num < b.num;
}
return a.id % 2 < b.id % 2;
}
return a.color < b.color;
}