Door: http://acm.hdu.edu.cn/showproblem.php? Pid = 1, 3682
Question:
I will give you a three-dimensional cube, removing a column each time, removing the m column, and asking you how many small cubes are removed 1*1*1 in total.
Question:
Mark each small cube with hash, store it with a vector, and finally remove the duplicate, the remaining instant answer.
AC code:
|
3682 |
203 MS |
4512 K |
2373 B |
G ++ |
|
# Include <iostream> # include <cstdio> # include <cstring> # include <string> # include <cstdlib> # include <cmath> # include <vector> # include <list> # include <deque> # include <queue> # include <iterator> # include <stack> # include <map> # include <set> # include <algorithm> # include <cctype> using namespace std; # define si1 (a) scanf ("% d", & a) # define I2 (a, B) scanf ("% d", & a, & B) # define sd1 (a) scanf ("% lf", & a) # define sd2 (a, B) scanf ("% lf", & a, & B) # define ss1 (s) scanf ("% s", s) # define pi1 (a) printf ("% d \ n", a) # define pi2 (a, B) printf ("% d \ n", a, B) # define mset (a, B) memset (a, B, sizeof (a) # define forb (I, a, B) for (int I = a; I <B; I ++) # define ford (I, a, B) for (int I =; I <= B; I ++) typedef long LL; const int N = 33; const int INF = 0x3f3f3f3f; const double PI = acos (-1.0 ); const double eps = 1e-8; vector <int> num; int main () {// freopen ("input.txt", "r", stdin); int nCase; int n, m; scanf ("% d", & nCase); while (nCase --) {num. clear (); int len = 0; scanf ("% d", & n, & m); getchar (); while (m --) {char a, B; int val1, val2; scanf ("% c = % d, % c = % d", & a, & val1, & B, & val2); getchar (); if (a = 'X') {if (B = 'y') for (int I = 1; I <= n; I ++) num. push_back (val1 * n + val2 * n + I); else for (int I = 1; I <= n; I ++) num. push_back (val1 * n + I * n + val2);} if (a = 'y') {if (B = 'X ') for (int I = 1; I <= n; I ++) num. push_back (val2 * n + val1 * n + I); else for (int I = 1; I <= n; I ++) num. push_back (I * n + val1 * n + val2);} if (a = 'Z') {if (B = 'X ') for (int I = 1; I <= n; I ++) num. push_back (val2 * n + I * n + val1); else for (int I = 1; I <= n; I ++) num. push_back (I * n + val2 * n + val1) ;}} sort (num. begin (), num. end (); // sort num. erase (unique (num. begin (), num. end (), num. end (); // deduplicated printf ("% d \ n", num. size () ;}return 0 ;}