String processing codeforces Round #285 (Div. 2) b. Misha and changing Handles

Source: Internet
Author: User

Topic Portal

1 /*2 Test Instructions: Give a series of name changes, ask what the last name became3 string Processing: Each time the input to the previous name of the printing, if not, it is the initial, Pos[m] array record the initial position4 the initial POS is added to each update, so the initial name is guaranteed to be updated, which is the only place to think about:)5 */6#include <cstdio>7#include <iostream>8#include <cstring>9#include <algorithm>Ten#include <cmath> One#include <string> A#include <map> -#include <ctime> - using namespacestd; the  - Const intMAXN = 1e3 +Ten; - Const intINF =0x3f3f3f3f; - stringOLD[MAXN]; + stringCHANGE[MAXN]; - stringANS[MAXN]; + intPOS[MAXN]; A  at intMainvoid)//codeforces Round #285 (Div. 2) b. Misha and changing Handles - { -Freopen ("b.in","R", stdin); -  -     intN; -      while(SCANF ("%d", &n) = =1) in     { -memset (POS,0,sizeof(POS)); to         stringtmpintm =0; +          for(intI=1; i<=n; ++i) -         { theCIN >> TMP; CIN >>Change[i]; *             BOOLOK =false; $              for(intj=1; j<i; ++j)Panax Notoginseng             { -                 if(TMP = =Change[j]) the                 { +OK =true; AANS[POS[J]] =Change[i]; thePos[i] = Pos[j]; Break; +                 } -             } $             if(!OK) $             { -OLD[++M] = tmp;    ANS[M] = Change[i]; Pos[i] =m; -             } the         } - Wuyiprintf ("%d\n", m); the          for(intI=1; i<=m; ++i) -         { Wucout << Old[i] <<" "<< Ans[i] <<Endl; -         } About     } $  -     //cout << "Time:" << (double) clock ()/clocks_per_sec * + << "ms\n"; -  -     return 0; A}

String processing codeforces Round #285 (Div. 2) b. Misha and changing Handles

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.