#2321058

Solution for 0580: Fish by olphe

Source Code Status Test Cases
    Policy: public     Reviewed: 15    
00.00 sec    6844 KB    89 lines     2080 bytes    2017-05-17 04:54
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int N,K;
long long int x[100];
long long int y[100];
long long int z[100];
long long int xbox[100];
long long int ybox[100];
long long int zbox[100];
int sum[100][100][100];
long long int ans;

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> x[i * 2] >> y[i * 2] >> z[i * 2] >> x[i * 2 + 1] >> y[i * 2 + 1] >> z[i * 2 + 1];
		xbox[i * 2] = x[i * 2];
		xbox[i * 2 + 1] = x[i * 2 + 1];
		ybox[i * 2] = y[i * 2];
		ybox[i * 2 + 1] = y[i * 2 + 1];
		zbox[i * 2] = z[i * 2];
		zbox[i * 2 + 1] = z[i * 2 + 1];
	}
	stable_sort(x, x + N * 2);
	stable_sort(y, y + N * 2);
	stable_sort(z, z + N * 2);
	//for (int i = 0; i < N * 2; i++) {
	//	cout << x[i] << " ";
	//}
	//cout << endl;
	//for (int i = 0; i < N * 2; i++) {
	//	cout << y[i] << " ";
	//}
	//cout << endl;
	//for (int i = 0; i < N * 2; i++) {
	//	cout << z[i] << " ";
	//}
	//cout << endl;
	for (int i = 0; i < N; i++) {
		int sx = 0, sy = 0, sz = 0, gx = 0, gy = 0, gz = 0;
		for (int j = 0; j < N * 2; j++) {
			if (xbox[i * 2] == x[j])sx = j;
			if (xbox[i * 2 + 1] == x[j])gx = j;
			if (ybox[i * 2] == y[j])sy = j;
			if (ybox[i * 2 + 1] == y[j])gy = j;
			if (zbox[i * 2] == z[j])sz = j;
			if (zbox[i * 2 + 1] == z[j])gz = j;
		}
	//	cout << sx << " " << gx << " " << sy << " " << gy << " " << sz << " " << gz << endl;
		for (int j = sx; j < gx; j++) {
			for (int k = sy; k < gy; k++) {
				for (int l = sz; l < gz; l++) {
					sum[j][k][l]++;
				}
			}
		}
	}
	for (int i = 0; i < N * 2 - 1; i++) {
		for (int j = 0; j < N * 2 - 1; j++) {
			for (int k = 0; k < N * 2 - 1; k++) {
				if (sum[i][j][k]>=K){
					ans += (x[i + 1] - x[i])*(y[j + 1] - y[j])*(z[k + 1] - z[k]);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Compile Error Logs:
You are not authorized to see the message.

Status
Judge: 5/5 C++14 CPU: 00.00 sec Memory: 6844 KB Length: 2080 B 2017-05-17 04:54 2017-05-17 04:54
Results for testcases
Case # Verdict CPU Time Memory In Out Case Name
Case #1: : Accepted 00.00 sec 3272 KB
Case #2: : Accepted 00.00 sec 6688 KB
Case #3: : Accepted 00.00 sec 6392 KB
Case #4: : Accepted 00.00 sec 6844 KB
Case #5: : Accepted 00.00 sec 6776 KB
< prev | / | next >  
 
Judge Input #  ( | ) Judge Output #  ( | )


Comments
 
 Under Construction.
 
Categories
 
 
Free Tags