QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#507788 | #8340. 3 Sum | ucup-team2307# | Compile Error | / | / | C++20 | 2.8kb | 2024-08-06 20:55:44 | 2024-08-06 20:55:44 |
Judging History
你现在查看的是最新测评结果
- [2024-09-20 10:20:30]
- hack成功,自动添加数据
- (/hack/848)
- [2024-08-06 20:55:44]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-08-06 20:55:44]
- 提交
answer
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
using namespace std;
#define int long long
using ll = __int128;
const int num_mods = 2;
const ll MOD1 = 4.7e17+1;
const array<ll, num_mods> mods = { MOD1, MOD1+3, MOD1+5, MOD1+7 };
array<int, num_mods> transform(vector<int> digits) {
array<int, num_mods> res;
for(int M = 0; M < num_mods; M++) {
ll cur = 1, ans = 0;
for(auto i : digits) {
ans = (ans + cur * 1ll * i) % mods[M];
cur = cur*10ll % mods[M];
}
res[M] = ans;
}
return res;
}
main() {
ios_base::sync_with_stdio(0);
cout.tie(0);
signed n, k;
// n = 500;
// k = 19000;
cin >> n >> k;
vector<string> s(n);
vector<vector<int>> nums;
for(auto &x : s) {
cin >> x;
// x = string(20000, '7');
reverse(x.begin(), x.end());
vector<int> digits(k);
for(int i = 0; i < x.size(); i++) {
digits[i % k] += x[i] - '0';
}
auto carry = [&]() {
for(int i = 0; i < digits.size(); i++) {
if(digits[i] >= 10) {
if(i + 1 == digits.size()) digits.push_back(0);
digits[i + 1] += digits[i] / 10;
}
digits[i] %= 10;
}
};carry();
while(digits.size() > k) {
if(digits.back() == 0) digits.pop_back();
else for(int i = k; i < digits.size(); i++) {
digits[i % k] += digits[i];
digits[i] = 0;
}
carry();
}
digits.resize(k);
nums.push_back(digits);
}
vector<array<int, num_mods>> T(n);
for(int i = 0; i < n; i++) T[i] = transform(nums[i]);
vector<int> MD(k, 9);
auto M = transform(MD);
auto solve = [&](array<int, num_mods> X) {
// map<array<int,
// for(auto i : X) cout << i << " "; cout << endl;
int ans = 0;
for(int i = 0; i < n; i++) {
// cout << T[i][0] << endl;
map<array<int, num_mods>, int> cnt;
for(int j = 0; j <= i; j++) {
cnt[T[j]]++;
array<int, num_mods> need;
for(int t = 0; t < num_mods; t++)
need[t] = (X[t] - T[i][t] - T[j][t] + 3ll * mods[t]) % mods[t];
ans += cnt[need];
// cout << i << " " << j << " "; for(auto x : need) cout << x << " "; cout << endl;
}
}
// cout << ans << endl << endl;
return ans;
};
ll ans = 0;
for(int i = 0; i < 3; i++) {
auto X = M;
for(int t = 0; t < num_mods; t++) X[t] = X[t] * 1ll * i % mods[t];
ans += solve(X);
}
cout << (int)(ans) << '\n';
}
詳細信息
answer.code:11:65: error: too many initializers for ‘const std::array<__int128, 2>’ 11 | const array<ll, num_mods> mods = { MOD1, MOD1+3, MOD1+5, MOD1+7 }; | ^ answer.code:26:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type] 26 | main() { | ^~~~