HDU 3682 To Be an Dream effecect (hash)

Source: Internet
Author: User

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 ;}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.