Bzoj 1142 [Poi2009]tab Simulation

Source: Internet
Author: User

Test Instructions:Link slightly Method:Simulation parsing:First if you do too much three then you must be aware that a matrix that is transformed by an arbitrary row and column will satisfy a property: The original line of the element is in that row, the original column in which the element is still in that column. and the inner elements of the rows can be exchanged arbitrarily. So violence can be verified. Code comes with 5K read-in optimization, Fury 艹 BZOJrnk1 Code:
#include <cstdio>#include <cstring>#include <cctype>#include <cstdarg>#include <iostream>#include <algorithm>#ifdef __gnuc__#include <unistd.h>#endif//#define UsingioexceptionStatic classscanner{typedef DoubleDtypedef unsigned int LongFITtypedef signed int LongSI;typedef unsigned CharStypedef CharCtypedef BOOLBStaticIiConstScL =16384, Eof =0xFF;#ifdef __gnuc__IiConstBuffer#elseFILE *ConstBuffer#endifS Ram[scl],*begin,*end; Public:#ifdef usingioexception    enumIOException {fileeof,typeerror};#endif#ifdef __gnuc__#ifdef FinScanner (IIConstIobuffer=open (Fin,1): Buffer (Iobuffer), Begin (RAM), End (RAM)#elseScanner (IIConstIobuffer=0): Buffer (Iobuffer), Begin (RAM), End (RAM)#endif#else#ifdef FinScanner (FILE *ConstIobuffer=fopen (Fin,"RB"): Buffer (Iobuffer), Begin (RAM), End (RAM)#elseScanner (FILE *ConstIobuffer=stdin): Buffer (Iobuffer), Begin (RAM), End (RAM)#endif#endif{} ~scanner (void)    {#ifdef __gnuc__Close (buffer);#elsefclose (buffer);#endif} II Get (void)    {if(Begin==end) {Begin=ram;#ifdef __gnuc__            if((end= (Begin=ram) +read (BUFFER,RAM,SCL)) ==ram)#else            if((end= (Begin=ram) +fread (RAM,1, Scl,buffer)) ==ram)#endif                returnEof; }return*begin++; } D GETSD (void) {II J; while(isspace(J=get ())); B neg=false;if(j=='-') {neg=true;        J=get (); }#ifdef usingioexception        if(!IsDigit(j))ThrowJ==eof? Fileeof:typeerror;#endifSI i=j-' 0 '; while(IsDigit(J=get ())) I= (i<<3) + (i<<1) + (J-' 0 ');if(j=='. ') {D Val=d (i), level=1.; while(IsDigit(J=get ())) val+= (level*=. 1) *d (J-' 0 ');returnNeg?-val:val; }returnNEG?-I:I; } D getd (void) {II J; while(isspace(J=get ()));#ifdef usingioexception        if(!IsDigit(j))ThrowJ==eof? Fileeof:typeerror;#endifII i=j-' 0 '; while(IsDigit(J=get ())) I= (i<<3) + (i<<1) + (J-' 0 ');if(j=='. ') {D Val=d (i), level=1.; while(IsDigit(J=get ())) val+= (level*=. 1) *d (J-' 0 ');returnVal }returnI } SI Getsi (void) {II J; while(isspace(J=get ())); B neg=false;if(j=='-') {neg=true;        J=get (); }#ifdef usingioexception        if(!IsDigit(j))ThrowJ==eof? Fileeof:typeerror;#endifSI i=j-' 0 '; while(IsDigit(J=get ())) I= (i<<3) + (i<<1) + (J-' 0 ');returnNEG?-I:I; } II getii (void) {II J; while(isspace(J=get ()));#ifdef usingioexception        if(!IsDigit(j))ThrowJ==eof? Fileeof:typeerror;#endifII i=j-' 0 '; while(IsDigit(J=get ())) I= (i<<3) + (i<<1) + (J-' 0 ');returnI } II GetS (void) {II J; while(isspace(J=get ()));#ifdef usingioexception        if(!isascii (j))ThrowJ==eof? Fileeof:typeerror;#endif        returnJ } c * Getcs (c *p) {skip (); while(!isspace(*p++=get ())); *--p=' + ';returnP }voidSkipint(*ConstFunc) (int)=isspace)    { while(Func (Get ()));    --begin; }}scan;Static classprinter{typedef unsigned int LongII;typedef CharCStaticIiConstScL =16384, Ral = -; C self[scl+ral],*sp,*ConstSlimit; FILE *ConstBuffer Public:#ifdef FoutPrinter (FILE *ConstIobuffer=fopen (Fout,"WB"): SP (self), slimit (SELF+SCL), buffer (Iobuffer)#elsePrinter (FILE *ConstIobuffer=stdout): SP (self), slimit (SELF+SCL), buffer (Iobuffer)#endif{} ~printer (void) {flush ();    fclose (buffer); }voidFlushvoid) {fwrite (self,1, Sp-self,buffer);    sp=self; }voidPrint (CConst*ConstS,...)        {va_list h; Va_start (h,s);if((sp+=vsprintf(SP,S,H))        >=slimit) flush ();    Va_end (h); }void puts(CConst*Consts) {if((sp+=strlen(strcpy(sp,s)))    >=slimit) flush (); }void Putchar(IIConstx) {*sp++= (C) x;if(sp>=slimit) flush (); }}sysout;#define N 1000100using namespace STD;structnode{intx, y;} a[n<<1];intTintN,m;intb[1010][1010];intMain () {T=scan.getsi (); while(t--)        {N=scan.getsi (); M=scan.getsi (); for(intI=1; i<=n;i++) { for(intj=1; j<=m;j++) {intX                X=scan.getsi (); x+=1000000;            A[x].x=i,a[x].y=j; }        } for(intI=1; i<=n;i++) { for(intj=1; j<=m;j++) {B[i][j]=scan.getsi (); }        }intflag=0;if(!flag) { for(intI=1; i<=n;i++) { for(intj=2; j<=m;j++) {if(a[b[i][j]+1000000].x!=a[b[i][j-1]+1000000].x) {flag=1; Break;} }if(flag) Break; }        }if(flag) {puts("NIE");Continue;} for(intI=1; i<=m;i++) { for(intj=2; j<=n;j++) {if(a[b[j][i]+1000000].y!=a[b[j-1][i]+1000000].Y) {flag=1; Break;} }if(flag) Break; }if(flag)puts("NIE");Else puts("TAK"); }}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Bzoj 1142 [Poi2009]tab Simulation

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.