# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
262756 |
2020-08-13T08:15:21 Z |
임성재(#5086) |
Pairs (IOI07_pairs) |
C++17 |
|
683 ms |
524292 KB |
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define pre(a) cout << fixed; cout.precision(a);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define all(v) (v).begin() (v).end()
#define mp make_pair
#define mt make_tuple
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;
struct point {
ll x[3];
point() {
x[0] = x[1] = x[2] = 0;
}
bool operator<(point &p) {
return mt(x[0], x[1], x[2]) < mt(p.x[0], p.x[1], p.x[2]);
}
};
ll b, n, d, m;
point p[100010];
ll dp[230][80][80][80];
int dp2[230][80][80][80];
int dp3[230][80][80][80];
//int cnt[80][80][80];
ll dist(int i, int j) {
ll ret = 0;
for(int k=0; k<3; k++) {
ret += abs(p[i].x[k] - p[j].x[k]);
}
return ret;
}
int main() {
fast;
cin >> b >> n >> d >> m;
for(int i=1; i<=n; i++) {
for(int j=0; j<b; j++) {
cin >> p[i].x[j];
}
dp[0][p[i].x[0]][p[i].x[1]][p[i].x[2]]++;
}
if(b == 1) {
sort(p+1, p+n+1);
ll ans = 0;
int idx = 1;
for(int i=1; i<=n; i++) {
while(idx <= n && dist(idx, i) <= d) idx++;
ans += idx - i - 1;
}
cout << ans;
return 0;
}
if(b == 2) {
sort(p+1, p+n+1);
for(int i=1; i<=n; i++) {
int x = p[i].x[0];
int y = p[i].x[2];
}
}
if(b == 3) {
for(int i=1; i<=m-1; i++) {
for(int j=1; j<=m; j++) {
for(int k=1; k<=m; k++) {
for(int l=1; l<=m; l++) {
dp[i][j][k][l] += dp[i-1][j+1][k][l];
dp[i][j][k][l] += dp[i-1][j-1][k][l];
if(i > 1 && j > 1 && j < m) dp[i][j][k][l] -= dp[i-2][j][k][l];
if(i == 2) dp[i][j][k][l] -= dp[0][j][k][l];
//cout << i << " " << j << " " << k << " " << l << " " << dp[i][j][k][l] << endl;
}
}
}
}
//cout << endl;
for(int i=0; i<=2*m-2; i++) {
for(int j=1; j<=m; j++) {
for(int k=1; k<=m; k++) {
for(int l=1; l<=m; l++) {
dp2[i][j][k][l] = dp[i][j][k][l];
if(i == 0) continue;
dp2[i][j][k][l] += dp2[i-1][j][k-1][l];
dp2[i][j][k][l] += dp2[i-1][j][k+1][l];
if(i > 1 && k > 1 && k < m) dp2[i][j][k][l] -= dp2[i-2][j][k][l];
if(i > 1) dp2[i][j][k][l] -= dp[i-2][j][k][l];
//cout << i << " " << j << " " << k << " " << l << " " << dp[i][j][k][l] << endl;
}
}
}
}
//cout << endl;
for(int i=0; i<=3*m-3; i++) {
for(int j=1; j<=m; j++) {
for(int k=1; k<=m; k++) {
for(int l=1; l<=m; l++) {
dp3[i][j][k][l] = dp2[i][j][k][l];
if(i == 0) continue;
dp3[i][j][k][l] += dp3[i-1][j][k][l-1];
dp3[i][j][k][l] += dp3[i-1][j][k][l+1];
if(i > 1 && l > 1 && l < m) dp3[i][j][k][l] -= dp3[i-2][j][k][l];
if(i > 1) dp3[i][j][k][l] -= dp2[i-2][j][k][l];
//cout << i << " " << j << " " << k << " " << l << " " << dp3[i][j][k][l] << endl;
}
}
}
}
for(int i=1; i<=d; i++) {
for(int j=1; j<=m; j++) {
for(int k=1; k<=m; k++) {
for(int l=1; l<=m; l++) {
dp3[i][j][k][l] += dp3[i-1][j][k][l];
}
}
}
}
ll ans = 0;
for(int i=1; i<=m; i++) {
for(int j=1; j<=m; j++) {
for(int k=1; k<=m; k++) {
//if(dp3[d][i][j][k]) cout << i << " " << j << " " << k << " " << dp3[d][i][j][k] << endl;
ans += (dp3[d][i][j][k]-1) * dp[0][i][j][k];
}
}
}
cout << ans / 2;
return 0;
}
}
Compilation message
pairs.cpp: In function 'int main()':
pairs.cpp:79:8: warning: unused variable 'x' [-Wunused-variable]
79 | int x = p[i].x[0];
| ^
pairs.cpp:80:8: warning: unused variable 'y' [-Wunused-variable]
80 | int y = p[i].x[2];
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2816 KB |
Output is correct |
2 |
Correct |
2 ms |
2816 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
88 ms |
2688 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
7168 KB |
Output is correct |
2 |
Correct |
21 ms |
7168 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
88 ms |
2688 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
94 ms |
2688 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
88 ms |
2760 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
32 ms |
8320 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
64 ms |
53992 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
83 ms |
2816 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
639 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
7800 KB |
Output is correct |
2 |
Correct |
26 ms |
7808 KB |
Output is correct |
3 |
Correct |
29 ms |
7800 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
613 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
683 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |