Submission #931777


Source Code Expand

Copy
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include <utility>
#include <cstdio>
#include<algorithm>
#include<queue>
#define ll  long long

using namespace std;
	int n;
void rotate(vector<int> & vec){
    vector<int> tmp(4);
    int minind = min_element(vec.begin(), vec.end() ) - vec.begin();
    for(int i=3; i>0; i--){
	if(vec[i]==vec[minind]){
	    minind=i;
	}else{
	    break;
	}
    }
    for(int i=0; i<4; i++){
	tmp[i] = vec[(i+minind)%4];
    }
    vec=tmp;
}
void rot1(vector<int> & vec){
    int tmp = vec[0];
    for(int i=0; i<4; i++){
	vec[i] = vec[i+1];
    }
    vec[3]=tmp;
}
int cntsq(vector<vector<int> > & c, vector<int>  & sq, int st, int sk){
    int res=0;
    for(int i=st; i<n; i++)
	if(i!=sk && c[i]==sq)res++;
    return res;
}
int sym(vector<int> v){
    if(v[0]!=v[2] || v[1]!=v[3])return 1;
    if(v[0]!=v[1] || v[2]!=v[3])return 2;
    return 4;
}
int main(){
    cin>>n;
    vector<vector<int> > c(n, vector<int>(4));
    for(int i=0; i<n; i++){
	for(int j=0; j<4; j++ )cin>>c[i][j];
	rotate(c[i]);
    }
    ll res = 0;
    for(int f = 0; f<n; f++){
	for(int s=f+1; s<n; s++){
	    for(int r=0; r<4; r++){
		ll mu=1;
		map<vector<int>, int> occ; occ.clear();
		for(int i=0; i<4; i++){
		    vector<int> tmp(4);
		    tmp[1] = c[f][i]; tmp[0] = c[f][(i+1)%4];
		    tmp[3] = c[s][3-(i+1)%4]; tmp[2] = c[s][3-i];
		    rotate(tmp);
		    mu*=(cntsq(c, tmp, f+1, s)-occ[tmp])*sym(tmp);
//cout<<f<<" "<<s<<" "<<r<<" "<<i<<" "<<cntsq(c, tmp, f+1, s)<<" "<<mu<<"\n";
//cout<<tmp[0]<<tmp[1]<<tmp[2]<<tmp[3]<<"\n";
		    occ[tmp]++;
		}
		res+=mu;
		rot1(c[s]);
//		cout<<c[s][0]<<c[s][1]<<c[s][2]<<c[s][3]<<"\n";
	    }
	}
    }
    cout<<res;
}

Submission Info

Submission Time
Task E - Building Cubes with AtCoDeer
User bas
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1767 Byte
Status
Exec Time 3819 ms
Memory 384 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_000.txt, 0_001.txt, 0_002.txt
All 0 / 900 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt
Case Name Status Exec Time Memory
0_000.txt 3 ms 256 KB
0_001.txt 3 ms 256 KB
0_002.txt 3 ms 256 KB
1_003.txt 1903 ms 256 KB
1_004.txt 51 ms 256 KB
1_005.txt 3106 ms 384 KB
1_006.txt 1820 ms 256 KB
1_007.txt 3819 ms 256 KB
1_008.txt 3148 ms 256 KB
1_009.txt 3701 ms 256 KB
1_010.txt 220 ms 256 KB
1_011.txt 3435 ms 256 KB
1_012.txt 6 ms 256 KB
1_013.txt 2948 ms 256 KB
1_014.txt 9 ms 256 KB
1_015.txt 2916 ms 256 KB
1_016.txt 465 ms 256 KB
1_017.txt 2912 ms 256 KB
1_018.txt 2897 ms 256 KB
1_019.txt 2904 ms 384 KB