Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
2989ms 險過紀錄一下 #include <cstdio> #include <cstring> #include <vector> #include <algorithm> using namespace std; typedef long long ll; #define MOD 14997 #define N 100004 #define L 8 #define pb push_back #define sz size () vector <int> vec[MOD]; int snow[N][L]; inline void get (int idx) { int sum=0, i; for (i = 0 ; i < 6 ; i ++)scanf ("%d", snow[idx]+i), sum+=snow[idx][i]; vec[sum%MOD].pb (idx); } inline bool alike (int a, int b) { int i; for (i = 0 ; i < 6 ; i ++) if (snow[a][i] == snow[b][0]) { int j; for (j = 0 ; j < 6 ; j ++) if (snow[b][j]!=snow[a][(i+j)%6])break; if (j==6)return true; for (j = 0 ; j < 6 ; j ++) if (snow[b][j]!=snow[a][(i-j+6)%6])break; if (j==6)return true; }return false; } inline bool test (int idx) { int i, j; for (i = 0 ; i < vec[idx].sz ; i ++) for (j = i+1 ; j < vec[idx].sz ; j ++) if (alike (vec[idx][i], vec[idx][j]))return true; return false; } inline bool check () { int i; for (i = 0 ; i < MOD ; i ++) if (test (i))return true; return false; } int main () { int n, i;scanf ("%d", &n); for (i = 0 ; i < n ; i ++)get (i); bool is=check (); if (is)puts ("Twin snowflakes found."); else puts ("No two snowflakes are alike."); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator