Submission #2703226


Source Code Expand

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N;
vi a[400];
ll ans = 0;
unordered_map<ll,int> u;

ll hsh(vi v) {
    return v[0]+1000LL*v[1]+1000000LL*v[2]+1000000000LL*v[3];
}

vi rot(vi a, int b) {
    rotate(a.begin(),a.begin()+b,a.end());
    return a;
}

ll minRot(vi a) {
    ll z = 1e12;
    F0R(i,4) z = min(z,hsh(rot(a,i)));
    return z;
}

void ad(int x, int ind) {
    F0R(i,4) u[hsh(rot(a[x],i))] += ind;
}

void tri(int x, int y) {
    F0R(i,4) {
        vi t1 = a[x]; 
        vi t2 = rot(a[y],i); reverse(all(t2));
        
        ll num = 1;
        vl p;
        
        F0R(j,4) {
            vi z = {t2[j],t2[(j+1)%4],t1[(j+1)%4],t1[j]};
            ll Z = hsh(z);
            ll tnum = u[Z];
            for (auto a: p) if (a == Z) tnum --;
            num *= tnum;
            F0R(i,4) p.pb(hsh(rot(z,i)));
        }
        ans += num;
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    F0R(i,N) {
        a[i].resize(4);
        F0R(j,4) cin >> a[i][j];
        ad(i,1);
    }
    F0R(i,N) {
        ad(i,-1);
        FOR(j,i+1,N) {
            ad(j,-1);
            tri(i,j);
            ad(j,1);
        }
    }
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Submission Info

Submission Time
Task E - Building Cubes with AtCoDeer
User Benq
Language C++14 (GCC 5.4.1)
Score 900
Code Size 2430 Byte
Status AC
Exec Time 1070 ms
Memory 61584 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 900 / 900
Status
AC × 3
AC × 20
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 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 AC 1 ms 256 KB
0_001.txt AC 1 ms 256 KB
0_002.txt AC 1 ms 256 KB
1_003.txt AC 516 ms 256 KB
1_004.txt AC 34 ms 256 KB
1_005.txt AC 511 ms 256 KB
1_006.txt AC 365 ms 256 KB
1_007.txt AC 514 ms 256 KB
1_008.txt AC 457 ms 256 KB
1_009.txt AC 514 ms 256 KB
1_010.txt AC 75 ms 256 KB
1_011.txt AC 498 ms 768 KB
1_012.txt AC 4 ms 384 KB
1_013.txt AC 991 ms 61328 KB
1_014.txt AC 8 ms 896 KB
1_015.txt AC 1070 ms 61584 KB
1_016.txt AC 220 ms 16500 KB
1_017.txt AC 1006 ms 61584 KB
1_018.txt AC 1003 ms 61584 KB
1_019.txt AC 1028 ms 61584 KB