Codeforces 183a headquarters

Source: Internet
Author: User

Here is a question: codeforces 183a Zoo

I was surprised when I did not think about how to do this. Although I noticed that the two examples made up a square, I still didn't think about it.

You can draw one by yourself:

1. At the beginning, a vertex is [0, 0] in a row and a column.

2.1 go to the top left [-] [0, 1] and tilt two points in one row and two columns at 45 degrees.

2.2 go to the bottom right [] [0,-1] and tilt a row with 45 degrees, two columns and two vertices

2.3 go to the lower left [-] [0,-1] Two rows, one column, and two vertices

2.4 go to the upper right [] [], two rows, one column, and two vertices

You can also guess what the four directions are like. The rows and columns are added.

Therefore, after a few steps, a skewed rectangle is formed, and the number of points is the area of the rectangle.

Paste someone else's code

#include <string.h>#include <algorithm>using namespace std;typedef __int64 LL;#define inf 10000000#define N 20010int main (){LL n, num[5];char str[5];while (scanf ("%I64d", &n) != EOF) {memset(num, 0,sizeof(num));for (LL i = 0; i < n; ++i) {scanf ("%s", str);if(strcmp (str, "UR")==0) num[1] ++;if(strcmp (str, "UL")==0) num[2] ++;if(strcmp (str, "DR")==0) num[4] ++;if(strcmp (str, "DL")==0) num[3] ++;if(strcmp (str, "ULDR")==0) num[0] ++;}LL len1, len2, ans;len1 = 1 + num[1] + num[3] +num[0];len2 = 1 + num[2] + num[4] +num[0];ans = len1 *len2;printf("%I64d\n", ans);}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.