QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#333919 | #1965. Trio | NYCU_CartesianTree# | Compile Error | / | / | C++20 | 4.3kb | 2024-02-20 19:54:45 | 2024-02-20 19:54:46 |
Judging History
answer
using namespace std;
int num[2005][4];
int pre[10][10][10][10];
int get_pre(int *p1, int *p2){
int sum = pre[p2[0]][p2[1]][p2[2]][p2[3]];
int t[4];
for(int i = 0; i < 4; i++){
for(int j = 0; j < 4; j++){
t[j] = p2[j];
}
t[i] = p1[i];
sum -= pre[t[0]][t[1]][t[2]][t[3]];
}
for(int i = 0; i < 4; i++){
for(int j = 0; j < 4; j++){
if(i == j)
continue;
for(int k = 0; k < 4; k++){
t[k] = p2[k];
}
t[i] = p1[i];
t[j] = p1[j];
sum += pre[t[0]][t[1]][t[2]][t[3]];
}
}
for(int i = 0; i < 4; i++){
for(int j = 0; j < 4; j++){
t[j] = p1[j];
}
t[i] = p2[i];
sum -= pre[t[0]][t[1]][t[2]][t[3]];
}
sum += pre[p1[0]][p1[1]][p1[2]][p1[3]];
return sum;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
char c;
for(int i = 0; i < n; i++){
for(int j = 0; j < 4; j++){
cin >> c;
num[i][j] = c - '0';
}
pre[num[i][0]][num[i][1]][num[i][2]][num[i][3]] += 1;
}
for(int i = 1; i <= 9; i++){
for(int j = 1; j <= 9; j++){
for(int k = 1; k <= 9; k++){
for(int t = 1; t <= 9; t++){
pre[i][j][k][t] += pre[i - 1][j][k][t];
}
}
}
}
for(int i = 1; i <= 9; i++){
for(int j = 1; j <= 9; j++){
for(int k = 1; k <= 9; k++){
for(int t = 1; t <= 9; t++){
pre[i][j][k][t] += pre[i][j - 1][k][t];
}
}
}
}
for(int i = 1; i <= 9; i++){
for(int j = 1; j <= 9; j++){
for(int k = 1; k <= 9; k++){
for(int t = 1; t <= 9; t++){
pre[i][j][k][t] += pre[i][j][k - 1][t];
}
}
}
}
for(int i = 1; i <= 9; i++){
for(int j = 1; j <= 9; j++){
for(int k = 1; k <= 9; k++){
for(int t = 1; t <= 9; t++){
pre[i][j][k][t] += pre[i][j][k][t - 1];
}
}
}
}
cerr << pre[1][2][9][4] << '\n';
int tp1[4] = {0, 1, 4, 3}, tp2[4] = {1, 2, 9, 4};
cerr << get_pre(tp1, tp2) << '\n';
int ans = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(i == j)
continue;
vector<pair<int, int> > seg[4];
bool allsame = 1;
for(int k = 0; k < 4; k++){
if(num[i][k] == num[j][k]){
seg[k].push_back({num[i][k] - 1, num[i][k]});
}else{
allsame = 0;
int a = num[i][k], b = num[j][k];
if(a > b)
swap(a, b);
if(a > 1)
seg[k].push_back({0, a - 1});
if(b - a > 1)
seg[k].push_back({a, b - 1});
if(b < 9)
seg[k].push_back({b, 9});
}
}
for(auto &s0 : seg[0]){
for(auto &s1 : seg[1]){
for(auto &s2 : seg[2]){
for(auto &s3 : seg[3]){
int p1[4] = {s0.first, s1.first, s2.first, s3.first}, p2[4] = {s0.second, s1.second, s2.second, s3.second};
if(i == 0 && j == 2){
for(int tt = 0; tt < 4; tt++){
cerr << p1[tt] << ' ';
}
cerr << '\n';
for(int tt = 0; tt < 4; tt++){
cerr << p2[tt] << ' ';
}
cerr << '\n';
cerr << get_pre(p1, p2) << '\n';
}
ans += get_pre(p1, p2);
}
}
}
}
ans -= allsame;
}
}
cout << ans / 3 << '\n';
}
详细
answer.code: In function ‘int main()’: answer.code:37:5: error: ‘ios’ has not been declared 37 | ios::sync_with_stdio(0); | ^~~ answer.code:38:5: error: ‘cin’ was not declared in this scope 38 | cin.tie(0); | ^~~ answer.code:1:1: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’? +++ |+#include <iostream> 1 | using namespace std; answer.code:86:5: error: ‘cerr’ was not declared in this scope 86 | cerr << pre[1][2][9][4] << '\n'; | ^~~~ answer.code:86:5: note: ‘std::cerr’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’? answer.code:94:20: error: ‘pair’ was not declared in this scope 94 | vector<pair<int, int> > seg[4]; | ^~~~ answer.code:1:1: note: ‘std::pair’ is defined in header ‘<utility>’; did you forget to ‘#include <utility>’? +++ |+#include <utility> 1 | using namespace std; answer.code:94:13: error: ‘vector’ was not declared in this scope 94 | vector<pair<int, int> > seg[4]; | ^~~~~~ answer.code:1:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’? +++ |+#include <vector> 1 | using namespace std; answer.code:94:25: error: expected primary-expression before ‘int’ 94 | vector<pair<int, int> > seg[4]; | ^~~ answer.code:98:21: error: ‘seg’ was not declared in this scope 98 | seg[k].push_back({num[i][k] - 1, num[i][k]}); | ^~~ answer.code:103:25: error: ‘swap’ was not declared in this scope 103 | swap(a, b); | ^~~~ answer.code:105:25: error: ‘seg’ was not declared in this scope 105 | seg[k].push_back({0, a - 1}); | ^~~ answer.code:107:25: error: ‘seg’ was not declared in this scope 107 | seg[k].push_back({a, b - 1}); | ^~~ answer.code:109:25: error: ‘seg’ was not declared in this scope 109 | seg[k].push_back({b, 9}); | ^~~ answer.code:112:28: error: ‘seg’ was not declared in this scope 112 | for(auto &s0 : seg[0]){ | ^~~ answer.code:136:5: error: ‘cout’ was not declared in this scope 136 | cout << ans / 3 << '\n'; | ^~~~ answer.code:136:5: note: ‘std::cout’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?