"Bzoj" 3916: [Baltic2014]friends

Source: Internet
Author: User

http://www.lydsy.com/JudgeOnline/problem.php?id=3916

#include <bits/stdc++.h>using namespace Std;int N, ans[3];  Char s[2000005];void work (int. now) {int l=1, r=n-(n>>1), if (now<2) ++r; int flag=0;//printf ("%d\n", now); for (int I=0, tot=n>>1; i<tot; ++i) {if (S[l]!=s[r]) {//printf ("%d%d\n", L, R); if (now==0 | | flag) {ans[now]=0; return;} if (now==1) ans[now]=l, ++l;if (now==2) ans[now]=r, ++r;flag=1;--i; Continue;} ++l; ++r;} if (!flag) ans[now]=n-(n>>1);} BOOL Check (int x, int y) {if (ans[x]==0 | | ans[y]==0 | | ans[x]==ans[y]) return 1; return 0;} int main () {scanf ("%d%s", &n, S+1), if ((n&1) ==0) {puts ("not POSSIBLE"); return 0;} for (int i=0, i<3; ++i) work (i), if (!ans[0] &&!ans[1] &&!ans[2]) {puts ("not POSSIBLE"); return 0;} for (int i=0; i<3; ++i) for (int. j=0; j<3; ++j) if (i!=j &&!check (i, J)) {puts ("not UNIQUE"); return 0;} int pos=0;for (int i=0; i<3; ++i) if (Ans[i]) pos=ans[i]; for (int. i=0; i<3; ++i) printf ("%d\n", Ans[i]), for (int i=1, cnt=0; i<=n; ++i) {if (I==pos) Continue;putchar (s[i]); if (++cnt== (n>>1)) break;} return 0;}

  

Obviously you can enumerate this point and then hash it around = =

However, this may be a card + constant large.

We consider 3 cases = This point is to the left of the midpoint, to the midpoint, to the right of the midpoint.

Then calculate the answer to these three cases = = then line spicy = = (for example, if on the left, then we allow the left side of the wrong character when sweeping

"Bzoj" 3916: [Baltic2014]friends

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.