给洛谷填坑的spj……

这里提供了洛谷某些题的$special\ judge$,供需要的oier拿过去对拍.

1.P3825

#include "testlib.h"

using namespace std;

int n,d;
char num[50010];
int m;
char ans1[50010];
int pi,pj,hi,hj;
char opt;
char opt1,opt2;
int main(int argc ,char* argv[]) {
    registerTestlibCmd(argc,argv);
    n=inf.readInt();
    d=inf.readInt();
    for(int i=1;i<=n;i++) {
        while(opt!='x'&&opt!='c'&&opt!='a'&&opt!='b') opt=inf.readChar();
        num[i]=opt;
        opt=0;
    }
    opt=ans.readChar();
    if(opt=='-') {
        opt1=ouf.readChar();
        if(opt1!='-')  quitf(_wa, "On line 1 column 1, read %c, expected -1 . score:QAQ", opt1 );
        opt2=ouf.readChar();
        if(opt2!='1')  quitf(_wa, "On line 1 column 2, read %c, expected 1 . score:QWQ", opt2 );
        ouf.readEof();
        quitf(_ok, "congrdulation Accept answer is -1 score:pwp");
    }
    opt=0;
    for(int i=1;i<=n;i++) {
        opt=ouf.readChar();
        if(opt!='A'&&opt!='B'&&opt!='C') quitf(_wa, "On line 1 column %d, read %c, expected A or B or C . score:qwq", i , opt );
        ans1[i]=opt;
        if(ans1[i]-'A'+'a'==num[i]&&num[i]!='x') quitf(_wa, "On line 1 column %d, unexpect %c, \n the car cannot run in this map . \n score:qaq", i , opt );
        opt=0;
    }
    m=inf.readInt();
    for(int i=1;i<=m;i++) {
        opt1=opt2=0;
        pi=inf.readInt();
        while(opt1!='A'&&opt1!='B'&&opt1!='C') opt1=inf.readChar();
        pj=inf.readInt();
        while(opt2!='A'&&opt2!='B'&&opt2!='C') opt2=inf.readChar();
        if(ans1[pi]==opt1&&ans1[pj]!=opt2) quitf(_wa, "cannot accept the limit %d , unexpect %c in map %d score:pvp", i , ans1[pj] ,pj );
    }
    ouf.readEof();
    quitf(_ok, " perfect answer score: qvq" );
    return 0;
}
P3825

 

2.P3506

#include "testlib.h"
using namespace std;
//testdata.in
int n,k;
int a[500010];
char s[500010];
//testdata.out
int len;
//users.out
int l;int pos;
int num[500010];
int main(int argc,char *argv[]){
    registerTestlibCmd(argc,argv);
    n=inf.readInt();
    k=inf.readInt();
    for(int i=1;i<=n;i++) a[i]=inf.readInt();
    for(int i=1;i<=k;i++) {
        s[i]=0;
        while(s[i]!='>'&&s[i]!='<'&&s[i]!='=')
            s[i]=inf.readChar();
    }
    len=ans.readInt();
    l=ouf.readInt();
    if(l<len) quitf(_wa,"your answer is smaller than the standard output,expect %d found %d.score:qaq",len,l);
    for(int i=1;i<=l;i++) {
        num[i]=ouf.readInt();
        while(a[pos]!=num[i]) {
            pos++;
            if(pos>n) quitf(_wa,"your sloution isn't a Subsequence of the input,in %d.score:pvp.",i);
        }
    }
    for(int i=1;i<l;i++) {
        char opt=s[(i-1)%k+1];
        if(opt=='>') {
            if(num[i]<=num[i+1]) quitf(_wa,"your answer cannot satisfy the condition in %d.score:ovo",i);
        }
        else if(opt=='<') {
            if(num[i]>=num[i+1]) quitf(_wa,"your answer cannot satisfy the condition in %d.score:ovo",i);
        }
        else if(opt=='=') {
            if(num[i]!=num[i+1]) quitf(_wa,"your answer cannot satisfy the condition in %d.score:ovo",i);
        }
    }
    quitf(_ok,"the answer is correct.score:qwq");
    return 0;
}
P3506

 

3.P3493

#include "testlib.h"
using namespace std;
double ous,anf;
int main(int argc,char *argv[]){
    registerTestlibCmd(argc,argv);
    ous=ouf.readReal();
    anf=ans.readReal();
    if(abs(ous-anf)<=0.001) {
        quitf(_ok,"ok the answer is correct ");
    }
    else quitf(_wa,"wrong answer found %lf , expect %lf +-0.01",ous,anf);
    return 0;
}
P3493

 

4.P3478

#include "testlib.h"
using namespace std;
struct data{
    int v;int next;
}edge[2000100];
int alist[1000100];
int cnt;
void add(int u,int v){
    edge[++cnt].v=v;
    edge[cnt].next=alist[u];
    alist[u]=cnt;
    return ;
}
int dep[1000100];
long long anss;
long long uout;
int n;
int u,v;
int sroot,uroot;
void dfs(int fa,int x,int de){
    dep[x]=de;
    for(int nxt=alist[x];nxt;nxt=edge[nxt].next) {
        if(edge[nxt].v==fa) continue;
        dfs(x,edge[nxt].v,de+1);
    }
    return ;
}
int main(int argc, char *argv[]){
    registerTestlibCmd(argc, argv);
    n=inf.readInt();
    for(int i=1;i<n;i++){
        u=inf.readInt();
        v=inf.readInt();
        add(u,v),add(v,u);
    }
    sroot=ans.readInt();
    dfs(0,sroot,1);
    for(int i=1;i<=n;i++) anss+=dep[i];
    memset(dep,0,sizeof(dep));
    uroot=ouf.readInt(1,n);
    dfs(0,uroot,1);
    for(int i=1;i<=n;i++) uout+=dep[i];
    if(anss>uout) quitf(_wa, "Your answer is less than the correct answer,found %d,expect %d ,score:qwq", uout, anss);
    else if(anss==uout) quitf(_ok, "your answer is correct (ying ying ying) ,score:qaq" );
    else if(anss<uout) quitp(2.0, "the spj or the data has been attacked ,please connect kkksc03 to fix the data or spj ,score:QAQ" );
    return 0;
}
P3478

 

5.P3474

#include "testlib.h"
using namespace std;
long long mp[2100][2100];
int n;
long long k,now;
int yy1,xx1,yy2,xx2;
char opt;
int main(int argc,char *argv[]){
    registerTestlibCmd(argc,argv);
    k=inf.readLong();
    n=inf.readInt();
    for(int i=1;i<=n;i++)
      for(int j=1;j<=n;j++)
        mp[i][j]=inf.readLong();
    opt=ans.readChar();
    if(opt=='N'){
        opt=ouf.readChar();
        if(opt!='N') quitf(_wa,"wrong answer ,expect NIE,found %c,score:qwq",opt);
        opt=ouf.readChar();
        if(opt!='I') quitp(0.2,"wrong answer ,expect IE,found %c,score:qwq",opt);
        opt=ouf.readChar();
        if(opt!='E') quitp(0.6,"wrong answer ,expect E,found %c,score:qwq",opt);
        quitf(_ok,"correct answer ,score:pwp");
    }
    yy1=ouf.readInt();
    xx1=ouf.readInt();
    yy2=ouf.readInt();
    xx2=ouf.readInt();
    for(int i=xx1;i<=xx2;i++)
        for(int j=yy1;j<=yy2;j++){
            now+=mp[i][j];
        }
        if(now>2*k) quitf(_wa,"your sloution is lager than 2*k.score:pvp");
        if(now<k) quitf(_wa,"your sloution is less than k.score:qvq");
        quitf(_ok,"ok,correct! score:qaq");
        return 0;
}
P3474

 

6.P3022

#include "testlib.h"
using namespace std;
struct data{
    int u;int v;
}edge[100100];
int cnt;
void add(int u,int v){
    edge[++cnt].u=u;
    edge[cnt].v=v;
    return ;
}
int n,m;
int u,v;
int now;
int d[50100];
bool ins[100100];
int usr;int anf;
int main(int argc,char* argv[]) {
    registerTestlibCmd(argc,argv);
    n=inf.readInt();
    m=inf.readInt();
//    printf("%d %d\n",n,m);
    for(int i=1;i<=m;i++) {
        u=inf.readInt();
        v=inf.readInt();
        add(u,v);
//        printf("%d %d\n",u,v);
    }
    anf=ans.readInt();
    usr=ouf.readInt();
//    printf("%d %d\n",anf,usr);
    if(anf==-1){
        if(usr==-1) quitf(_ok,"the answer is -1 . score:qaq");
        else quitf(_wa,"wa……expect -1 found %d . score:qwq",usr);
    }
    for(int i=1;i<=usr;i++){
        now=ouf.readInt(1,m);
        if(ins[now]==true) quitf(_wa,"your sloution has been retain the edge %d before the operation %d/%d.score: qvq",now,i,usr);
        ins[now]=true;
        d[edge[now].u]++,d[edge[now].v]++;
    }
    for(int i=1;i<=n;i++) {
        if(!d[i]&1) quitf(_wa,"the degrees of the point %d isn't an odd ,is %d .score:pvp",i,d[i]);
    }
    quitf(_ok,"the answer is correct");

    return 0;
}
P3022

 

7.P2164

#include "testlib.h"
using namespace std;
const double eps = 0.1;
int n,m;
double a1,a2;
int main(int argc, char *argv[]){
    registerTestlibCmd(argc, argv);
    n=inf.readInt();
    m=inf.readInt();
    for(int i=1;i<=m;i++) {
        a1=ans.readDouble();
        a2=ouf.readDouble();
        if(abs(a1-a2)>eps) quitf(_wa,"wrong answer on line %d.score:qaq",i);
    }
    quitf(_ok,"correct answer.score:qwq");
    return 0;
}
P2164

 

8.P1871

#include "testlib.h"
//#include <iostream>
using namespace std;
string  pos[7]={"Success","Already","Conflict","on","with","off"};
int n,m;bool ins[100010];char opt;int now;//题解部分
int a,b,c;int lst;//多解检验部分
string ous;int cnt;//选手输出部分
string anf;//标准答案部分
int main(int argc,char *argv[])
{
    registerTestlibCmd(argc,argv);
    n=inf.readInt();m=inf.readInt();
    for(int i=1;i<=m;i++){
        opt=0;
        while(opt!='-'&&opt!='+') opt=inf.readChar();
        now=inf.readInt();
        if(opt=='+') {
            anf=ans.readToken();ous=ouf.readToken();
//            cout<<anf<<endl<<ous<<endl;
            if(anf!=ous) quitf(_wa,"wrong answer on operation %d .score:qaq",i);
            if(anf==pos[0]) ins[now]=true;
            else if(anf==pos[1]) {
                anf=ans.readToken();ous=ouf.readToken();
                if(ous!=anf) quitp(0.2,"wrong answer on operation %d,expect on.score:qoq",i);
            }
            else if(anf==pos[2]) {
                anf=ans.readToken();ous=ouf.readToken();
                if(anf!=ous) quitp(0.2,"wrong answer on operation %d,expect with .score:qoq",i);
                cnt=ans.readInt();cnt=ouf.readInt(1,n);
                if(ins[cnt]!=true) {
                    quitf(_wa,"on operation %d,the machin %d hasn't been opened .score:qwq",i,cnt);
                }
                if(__gcd(cnt,now)==1){
                    quitf(_wa,"on operation %d,the machin %d(opened) and the %d(will be opened) are not Conflict,score:pwp",i,cnt,now);
                }
            }
        }
        if(opt=='-') {
            anf=ans.readToken();ous=ouf.readToken();
            if(anf!=ous) quitf(_wa,"wrong answer on operation %d.score:qaq",i);
            if(anf==pos[0]) ins[now]=false;
            if(anf==pos[1]) {
                anf=ans.readToken();ous=ouf.readToken();
                if(anf!=ous) quitp(0.2,"wrong answer on operation %d,expect off.score:qoq",i);
            }
        }
    }
    quitf(_ok,"ok,correct answer");
    return 0;
}
P1871

 

9.P1248

#include "testlib.h"

using namespace std;
int n;
int a[1005];
int b[1005];
int sans;int uans;
int num[1005];
bool ins[1005];
int now_a;int now_b;
int now_ans;
int main(int argc ,char* argv[]) {
    registerTestlibCmd(argc,argv);
    n=inf.readInt();
    for(int i=1;i<=n;i++) a[i]=inf.readInt();
    for(int i=1;i<=n;i++) b[i]=inf.readInt();
    sans=ans.readInt();
    uans=ouf.readInt();
    if(sans!=uans) {
        quitf(_wa, "wrong answer On line 1 column 1, read %d, expected %d. score:qwq", uans, sans);
    }
    for(int i=1;i<=n;i++) num[i]=ouf.readInt(1,n),ins[num[i]]=true;
    for(int i=1;i<=n;i++) if(!ins[i]) quitf(_wa, "your solution cannot slove the product %d.score:qaq",i);
    for(int i=1;i<=n;i++) {
        int now=now_a+a[num[i]];
        if(now>now_b) now_b=now+b[num[i]];
        else now_b=now_b+b[num[i]];
        now_a+=a[num[i]];
    }
    now_ans=max(now_a,now_b);
    if(now_ans==uans)  quitf(_ok, "The answer is correct.");
    else if(now_ans<uans) quitp( 0.5 , "your sloution is smaller than your min time score:QAQ");
    else  quitf(_wa, "your sloution is bigger than your min time score:QWQ");
    return 0;
}
P1248

 

10.P4293

#include "testlib.h"
using namespace std;
const int maxn = 100010;
int n;
double m[maxn],c[maxn];
bool oc[maxn];
void rdin(){
    n=inf.readInt();
    for(int i=1;i<=n;i++) {
        m[i]=inf.readReal();
        c[i]=inf.readReal();
    }
    return ;
}
double calc ( int a , int b ) { return m[a] * m[b] * ( c[a] - c[b] ) ; }
double cb,ck;
bool idok ( int x ) { return ( x >= 1 and x <= n ); }
void rdout(){
    int a,b;a=ouf.readInt();b=ouf.readInt();
    if( idok(a) && idok(b) && a != b ) cb = calc( a , b );
    else cb = -1 ; ck = 0;
    int k,pr;k=ouf.readInt();memset(oc,0,sizeof(oc));pr=ouf.readInt();
    if(!idok(pr)) { ck = -1 ; return ;}
    oc[pr] = true;
    int fr = pr;
    int r1a = -1, r1b = -1, r2a = -1, r2b = -1;
    for(int i=1;i<k;i++) {
        int x;x=ouf.readInt();
        if( !idok(x) || oc[x] ) { ck = -1 ; return ;}
        oc[x]=true;
        double tmpc = calc( pr ,x );
        ck += tmpc;
        if(tmpc < 0) {
            if (r1a == -1) r1a = r1b = i;
            else if (i == r1b + 1) r1b = i;
            else if (r2a == -1) r2a = r2b = i;
            else if (i == r2b + 1) r2b = i;
            else { ck = -1; return ; }
        }
        pr = x;
    }
    ck += calc(pr , fr );
    if (r2b == k-1 && r1a == 1 ) ;
    else if (r2a != -1 ) ck = -1 ;
    return ;
}
void rdas(){
    int a,b;a=ans.readInt();b=ans.readInt();
    if( idok(a) && idok(b) && a != b ) cb = calc( a , b );
    else cb = -1 ; ck = 0;
    int k,pr;k=ans.readInt();memset(oc,0,sizeof(oc));pr=ans.readInt();
    if(!idok(pr)) { ck = -1 ; return ;}
    oc[pr] = true;
    int fr = pr;
    int r1a = -1, r1b = -1, r2a = -1, r2b = -1;
    for(int i=1;i<k;i++) {
        int x;x=ans.readInt();
        if( !idok(x) || oc[x] ) { ck = -1 ; return ;}
        oc[x]=true;
        double tmpc = calc( pr ,x );
        ck += tmpc;
        if(tmpc < 0) {
            if (r1a == -1) r1a = r1b = i;
            else if (i == r1b + 1) r1b = i;
            else if (r2a == -1) r2a = r2b = i;
            else if (i == r2b + 1) r2b = i;
            else { ck = -1; return ; }
        }
        pr = x;
    }
    ck += calc(pr , fr );
    if (r2b == k-1 && r1a == 1 ) ;
    else if (r2a != -1 ) ck = -1 ;
    return ;
}
double cb_ans,ck_ans;
void rdans() {
    rdas();
    cb_ans = cb;
    ck_ans = ck;
}
const double eps = 1e-5;
bool ok ( double r , double e) {
    if( r >= e - eps) return true;
    if( r/e >= 1 - eps) return true;
    return false;
}
void processout() {
    rdout();
    int t = 0;
    if( ok ( cb , cb_ans ) ) t++;
    if( ok ( ck , ck_ans ) ) t+=2;
    if(t == 3) quitf(_ok,"ok ,the answer is correct");
    else if( t == 2 ) quitp(0.5,"Right 2");
    else if( t == 1 ) quitp(0.5,"Right 1");
    else quitf(_wa,"wrong answer");
}
int main(int argc,char *argv[]){
    registerTestlibCmd(argc,argv);
    rdin();
    rdans();
    processout();
    return 0;
}
P4293

 

11.P3596

#include "testlib.h"
using namespace std;
const int maxn = 1e6 + 10;
struct in{int u;int v;}qus[maxn << 1];
struct data{int v;int next;}edge[maxn<<1];int alist[maxn];int cnt;
void add(int u,int v){edge[++cnt].v=v;edge[cnt].next=alist[u];alist[u]=cnt;return ;}
int maxx,xx1,yy1,xx2,yy2;
int minn;int anss;int maxd;int po;int dis[maxn];
void dfs(int x,int fa) {
    if(x==xx2&&fa!=yy2) {
        int v=yy2;dis[v]=dis[x]+1;
        if(dis[v]>maxd) maxd=dis[v],po=v;dfs(v,x);
    }
    if(x==yy2&&fa!=xx2) {
        int v=xx2;dis[v]=dis[x]+1;
        if(dis[v]>maxd) maxd=dis[v],po=v;dfs(v,x);
    }
    for(int next=alist[x];next;next=edge[next].next) {
        if(x==xx1&&edge[next].v==yy1) continue;
        if(edge[next].v==xx1&&x==yy1) continue;
        if(edge[next].v==fa) continue;
        dis[edge[next].v]=dis[x]+1;
        if(dis[edge[next].v]>maxd) maxd=dis[edge[next].v],po=edge[next].v;
        dfs(edge[next].v,x);
    }
}
int n,m;int u,v;bool che1,che2;
int main(int argc,char *argv[]){
    registerTestlibCmd(argc,argv);
    n=inf.readInt();
    for(int i=1;i<n;i++) u=inf.readInt(),v=inf.readInt(),qus[i].u=u,qus[i].v=v;
    anss=ans.readInt();maxx=ouf.readInt();
    if(anss<maxx) quitf(_wa,"wrong answer on line 1 cloum 1 ,found %d ,expexct %d.score:qaq",maxx,anss);
    xx1=ans.readInt();yy1=ans.readInt();xx2=ans.readInt();yy2=ans.readInt();
    xx1=ouf.readInt();yy1=ouf.readInt();xx2=ouf.readInt();yy2=ouf.readInt();
    for(int i=1;i<n;i++){
        if((qus[i].u==xx2&&qus[i].v==yy2)||(qus[i].u==yy2&&qus[i].v==xx2)) {che2=true;continue;}
        if((qus[i].u==xx1&&qus[i].v==yy1)||(qus[i].u==yy1&&qus[i].v==xx1)) {che1=true;continue;}
        add(qus[i].u,qus[i].v),add(qus[i].v,qus[i].u);}
    if(che1!=true||che2==true) quitf(_wa,"your sloution isn't correct .");
    dis[1] = 0;dfs(1,0);dis[po]=0;dfs(po,0);
    if(maxd!=maxx) quitf(_wa,"wrong answer.the sloution isn't equle to your answer on line 1");
    memset(dis,0,sizeof(dis));po=0;maxd=0;memset(edge,0,sizeof(edge));memset(alist,0,sizeof(alist));
    anss=ans.readInt();maxx=ouf.readInt();che1=che2=0;
    if(anss>maxx) quitf(_wa,"wrong answer on line 2 cloum 1 ,found %d ,expexct %d.score:qaq",maxx,anss);
    xx1=ans.readInt();yy1=ans.readInt();xx2=ans.readInt();yy2=ans.readInt();
    xx1=ouf.readInt();yy1=ouf.readInt();xx2=ouf.readInt();yy2=ouf.readInt();
    for(int i=1;i<n;i++){
        if((qus[i].u==xx2&&qus[i].v==yy2)||(qus[i].u==yy2&&qus[i].v==xx2)) {che2=true;continue;}
        if((qus[i].u==xx1&&qus[i].v==yy1)||(qus[i].u==yy1&&qus[i].v==xx1)) {che1=true;continue;}
        add(qus[i].u,qus[i].v),add(qus[i].v,qus[i].u);}
    if(che1!=true||che2==true) quitf(_wa,"your sloution isn't correct .");
    dis[1] = 0;dfs(1,0);dis[po]=0;dfs(po,0);
    if(maxd!=maxx) quitf(_wa,"wrong answer.the sloution isn't equle to your answer on line 2");
    quitf(_ok,"the answer is correct");
    return 0;
}
P3596

 

12.P3529 等待update

#include "testlib.h"
using namespace std;
const int maxn = 510;
int n,m,r,t,k;bool ins[maxn][maxn];
int ouss;int anss;int slo[maxn];int u,v;
struct data{
    int id;int pro;int tim;
    friend bool operator < (const data &a,const data &b) {return a.tim<b.tim;}
}qwq[maxn];int cnt;int nxt[maxn];
int main(int argc, char *argv[]) {
    registerTestlibCmd(argc,argv);
    n=inf.readInt();m=inf.readInt();r=inf.readInt();t=inf.readInt();k=inf.readInt();ouss=ouf.readInt();anss=ans.readInt();cnt=ouss;
    if(ouss<anss) quitf(_wa,"wrong answer on line 1 cloum 1,expect %d,found %d",anss,ouss);ouss=ouf.readInt();anss=ans.readInt();
    if(ouss>anss) quitf(_wa,"wrong answer on line 1 cloum 2,expect %d,found %d",anss,ouss);
    for(int i=1;i<=k;i++) u=inf.readInt(),v=inf.readInt(),ins[u][v]=true;
    for(int i=1;i<=cnt;i++) {qwq[i].id=ouf.readInt();qwq[i].pro=ouf.readInt();qwq[i].tim=ouf.readInt();}sort(qwq+1,qwq+1+cnt);
    for(int i=1;i<=cnt;i++) {
        if(nxt[qwq[i].id]>qwq[i].tim) quitf(_wa,"wrong answer on line %d+1,people %d  cannot work on time %d",i,qwq[i].id,qwq[i].tim);
        if(slo[qwq[i].pro]!=0) quitf(_wa,"wrong answer on line %d+1,the problem %d han been sloved before.",i,qwq[i].pro);
        if(ins[qwq[i].id][qwq[i].pro]==false) quitf(_wa,"wrong answer on line %d+1,the person %d cannot slove the problem %d.",i,qwq[i].id,qwq[i].tim);
        nxt[qwq[i].id]=qwq[i].tim;slo[qwq[i].pro]=qwq[i].tim+r;}
        int all = 0 ;
    for(int i=1;i<=m;i++) all+=slo[i];
    if(all==anss) quitf(_ok,"ok the answer is correct ");
    else quitf(_wa,"wrong answer,your sloutiion isn't equle to your answer.");
    return 0;
}
P3529

 

13.P3520 未完成

//#pragma gcc optimize(2)
#include "testlib.h"
using namespace std;
const int maxn = 1e6 + 10;
const int maxm = 2e7 + 10;
struct pre{int u;int v;bool val;bool end;}pre[maxm];
struct data{int v;int next;int val;}edge[maxn << 1];int alist[maxn];int cnt;
void add(int u,int v,int val)
    {edge[++cnt].v=v;edge[cnt].val=val;edge[cnt].next=alist[u];alist[u]=cnt;return ;}
int n,m;int u,v,vals,vale;
void rdin() {
    n=inf.readInt();m=inf.readInt();
    for(int i=1;i<=m;i++)
        pre[i].u=inf.readInt(),pre[i].v=inf.readInt(),
        pre[i].val=inf.readInt(),pre[i].end=inf.readInt();
    return ;
}
char opt;int ouss;int num;bool ins[maxn];int now[maxn];bool inss[maxn];
bool che(int fa,int x,int pos,int now_num) {
    if(pos==now_num) return true;bool qaq=false;
    for(int next=alist[x];next;next=edge[next].next){
        if(edge[next].v==fa) continue ;
        if(edge[next].v==now[pos+1]) qaq=true,pre[(next+1)>>1].val^=1;
    }
    if(qaq==true) return che(x,now[pos+1],pos+1,now_num);
    return false;
}
bool work() {
    memset(ins,false,sizeof(ins));memset(now,0,sizeof(now));num=ouf.readInt();
    for(int i=1;i<=num+1;i++) now[i]=ouf.readInt(),ins[now[i]]=true;
    bool book = che(now[num],now[1],1,num+1);
    if(!book) return false;
    return true;
}
int main(int argc, char *argv[]) {
    registerTestlibCmd(argc,argv);opt=ans.readChar();
    if(opt=='N') {
        opt=ouf.readChar();if(opt!='N') quitf(_wa,"on line 1 cloum 1 ecpect NIE found %c",opt);
        opt=ouf.readChar();if(opt!='I') quitf(_wa,"on line 1 cloum 1 ecpect IE found %c",opt);
        opt=ouf.readChar();if(opt!='E') quitf(_wa,"on line 1 cloum 1 ecpect E found %c",opt);
        quitf(_ok,"ok the answer is correct.");
    }
    rdin();ouss=ouf.readInt();
    for(int i=1;i<=m;i++) add(pre[i].u,pre[i].v,pre[i].val),add(pre[i].v,pre[i].u,pre[i].val);
    for(int i=1;i<=ouss;i++) if(!work()) quitf(_wa,"wrong answer ,your sloution isn't a single ring on line %d+1",i);
    for(int i=1;i<=m;i++) if(pre[i].val!=pre[i].end) quitf(_wa,"wrong answer ,your sloution cannow slove the road %",i);
    quitf(_ok,"ok,the answer is coerrect");
    return 0;
}
P3520

 

14.P3516

#include "testlib.h"
#include <ctime> 
using namespace std;
struct lb{
    int pre,nxt,val;
}x[2005];
int n,cnt,head,tail;
void ltof(int num)
{
    while(num--)
    {
        int ls=x[tail].pre;
        x[ls].nxt=0;
        x[tail].nxt=head;
        x[tail].pre=0;
        x[head].pre=tail;
        head=tail;
        tail=ls;
    }
}
void ttof(int num)
{
    while(num--)
    {
        int cnt=0;
        int ls=head;
        for(int i=1;i<=2;i++)
        {
            ls=x[ls].nxt;
        }
        int forth=x[ls].nxt;
        int kkk=x[ls].pre;
        x[forth].pre=kkk;
        x[kkk].nxt=x[ls].nxt;
        x[ls].pre=0;
        x[ls].nxt=head;
        x[head].pre=ls;
        head=ls;
    }
}
void change(int num,int cz){
    if(cz==0) ltof(num);
    else ttof(num);
}
char opt;int now;
char pos;
int m;
int main(int argc,char *argv[]) {
    registerTestlibCmd(argc,argv);
    n=inf.readInt();
    for(int i=1;i<=n;i++) x[i].val=inf.readInt(),x[i].pre=i-1,x[i].nxt=i+1;
    head=1,tail=n;int qnt=1;
    opt=ans.readChar();
    if(opt=='N') {
        pos=ouf.readChar();
        if(pos!='N') quitf(_wa,"expect NIE found %c.score:pqp",pos);
        pos=ouf.readChar();
        if(pos!='I') quitf(_wa,"expect IE found %c.score:pqp",pos);
        pos=ouf.readChar();
        if(pos!='E') quitf(_wa,"expect E found %c.score:pqp",pos);
        pos=ouf.readChar();
        if(pos=='\n'||pos==3||pos==26) quitf(_ok,"the answer ios corect .score:qaq");
        if(pos!=' ') quitf(_wa,"expect  found %c.score:pqp",pos);
        pos=ouf.readChar();
        if(pos!='D') quitf(_wa,"expect DA found %c.score:pqp",pos);
        pos=ouf.readChar();
        if(pos!='A') quitf(_wa,"expect A found %c.score:pqp",pos);
        pos=ouf.readChar();
        if(pos!=' ') quitf(_wa,"expect   found %c.score:pqp",pos);
        pos=ouf.readChar();
        if(pos!='S') quitf(_wa,"expect SIE found %c.score:pqp",pos);
        pos=ouf.readChar();
        if(pos!='I') quitf(_wa,"expect IE found %c.score:pqp",pos);
        pos=ouf.readChar();
        if(pos!='E') quitf(_wa,"expect E found %c.score:pqp",pos);
        quitf(_ok,"the answer ios corect .score:qaq");
    }
    m=ouf.readInt();
    
    if(n==1&&m==0) {quitf(_ok,"correct answer");return 0;}
    else if(n==1) {quitf(_wa,"wrong answer");return 0;}

    for(int i=1;i<=m;i++){
        pos=0;now=0;
        pos=ouf.readChar();
        while(pos>'9'||pos<'0') pos=ouf.readChar();
        while(pos<='9'&&pos>='0') now=now*10+pos-'0',pos=ouf.readChar();
        if(now<=0||now>n) quitf(_wa,"wrong output on operation %d,found %d,expect in [ 1 , %d ] .score:vov",i,now,n);
        if(pos=='b') now%=3;
        if(pos=='a') now%=n; 
        change(now,pos=='b');
        
    }
    int wz=head;
    while(wz!=tail){
        int nxt=x[wz].nxt;
        if(x[nxt].val<x[wz].val){
            quitf(_wa,"wrong answer");
            return 0;
        }
        wz=nxt;
    }
    if(x[x[tail].pre].val>x[tail].val) quitf(_wa,"worong answer ");
    else quitf(_ok,"correct answer ");
    return 0;
}
P3516

 

 

15.P2974

#include "testlib.h"
using namespace std;
const int maxn = 1010;
const int maxm = 5010;
string com[2]={"ATTACK","MOVE"};
int n,m;char mp[maxn];//testdata.in
struct data{int v;int next;}edge[maxm << 1];int alist[maxn];int cnt;
void add(const int &u,const int &v)
    {edge[++cnt].v=v;edge[cnt].next=alist[u];alist[u]=cnt;return ;}
string now;int anss;int usrr;//answer compair&&users output
bool ins[maxn];bool att[maxn];bool mov[maxn];int num;
bool unicom(const int &a,const int &b)
    {for(int next=alist[a];next;next=edge[next].next) if(edge[next].v==b) return true;else ;return false;}
bool move(const int &a,const int &b) {
    if(!unicom(a,b)) return false;
    if(mp[a]=='J'&&mp[b]=='E'&&mov[a]==false&&att[a]==false)
        mov[a]=true,swap(mp[a],mp[b]),swap(mov[a],mov[b]),swap(att[a],att[b]);
    else return false;return true;
}
int attack(const int &a,const int &b) {
    if(!unicom(a,b)) return -1;
    if(mp[a]=='J'&&mp[b]=='T'&&att[a]==false) {
        if(ins[b]==false) {ins[b]=true,att[a]=true;return true;}
        ins[b]=true,att[a]=true;return 0;
    }else return -1;
}
int u,v;int a,b;int pos;
int main(int argc, char *argv[]) {
    registerTestlibCmd(argc,argv);
    n=inf.readInt();m=inf.readInt();char opt=0;
//    for(int i=1;i<=m;i++) qus[i].u=inf.readInt(),qus[i].v=inf.readInt(),add(qus[i].u,qus[i].v),add(qus[i].v,qus[i].u);
    for(int i=1;i<=m;i++) u=inf.readInt(),v=inf.readInt(),add(u,v),add(v,u);
    anss=ans.readInt();usrr=ouf.readInt();
    if(anss!=usrr) quitf(_wa,"on line 1 cloum 1 expect %d found %d.score:qaq",anss,usrr);usrr=0;
    while(usrr!=anss) {
        now=ouf.readToken();a=ouf.readInt();b=ouf.readInt();
        if(now==com[0]) {
            int qwq=attack(a,b);
            if(qwq==-1) quitf(_wa,"wrong sloution ,the cow %d can't attack %d",a,b);
            else usrr+=qwq;}
        if(now==com[1]) if(!move(a,b)) quitf(_wa,"you cannot move %d to %d",a,b);
    }
    quitf(_ok,"ok,the answer is correct");
    return 0;
}
//
P2974

 

16.P2565

#include "testlib.h"
using namespace std;
const double eps = 1e-6 ;
const int maxn = 220;
int as[maxn][maxn];
int a[maxn];
int n,m;
bool pd() {
    for(int i=1;i<=n;i++) {
        int tmp = 0 ;
        for(int j = 1 ; j <= m ; j ++ )
          for(int k = 1 ; k <= m ; k ++ )
            if( as[i][j] > as[a[i]][k] )
              tmp++;
        if( tmp * 2 <= m * m ) return 0;
    }
    return 1;
}
bool ins[41100];
int main(int argc,char *argv[]){
    registerTestlibCmd(argc,argv);
    int p1,p2;
    p1=ans.readInt();
    if(p1 == 0 ) {
        p2=ouf.readInt();
        if(p1==p2) quitf(_ok,"corrcet answer.score:ovo");
        quitf(_wa,"wrong answer,expect 0 ,found %d,score:qaq",p2);
    }
    n=inf.readInt();
    m=inf.readInt();
    for(int i=1;i<=n;i++) a[i]=inf.readInt();
    for(int i=1;i<=n;i++)
      for(int j=1;j<=m;j++){
        as[i][j]=ouf.readInt();
        if(ins[as[i][j]]==true) quitf(_wa,"on line %d,cloumb %d,the number %d had foung before.score:qwq",i,j,as[i][j]);
        ins[as[i][j]]=true;
      }
    if(pd()) quitf(_ok,"the answer is correct.score:pwp");
    else quitf(_wa,"wrong asnwer . score:pvp");
    return 0;
}
P2565

 

17.P1253

#include "testlib.h"
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = 10010;
int n;
long long p[maxn];
long long l[maxn];
long long now[maxn];
long long t[maxn];
long long sums[maxn];
long long sumo[maxn];
long long anss;
long long anso;
void readin(){
//    freopen("10.in","r",stdin);
    n=inf.readInt();
    for(int i=1;i<=n;i++) l[i]=inf.readLong(),p[i]=inf.readLong(),now[i]=l[i]*p[i];
//    fclose(stdin);
}
void readas(){
//    freopen("10.ans","r",stdin);
    for(int i=1;i<=n;i++) t[i]=ans.readLong();
    for(int i=1;i<=n;i++) sums[i]=now[t[i]];
    for(int i=1;i<=n;i++) sums[i]=sums[i-1]+sums[i];
    for(int i=1;i<=n;i++) anss+=sums[i];
//    fclose(stdin);
}
void reados(){
//    freopen("10.out","r",stdin);
    for(int i=1;i<=n;i++) t[i]=ouf.readLong();
    for(int i=1;i<=n;i++) sumo[i]=now[t[i]];
    for(int i=1;i<=n;i++) sumo[i]=sumo[i-1]+sumo[i];
    for(int i=1;i<=n;i++) anso+=sumo[i];
//    fclose(stdin);
}
int main(int argc,char *argv[]){
    registerTestlibCmd(argc,argv);
    readin();
    readas();
    reados();
//    printf("%lld %lld\n%lld",anss,anso,anss-anso);
    if(anss==anso) quitf(_ok,"the answer is correct");
    else quitf(_wa,"the minnument time is %d , but your sloution is %d",anss,anso);
    return 0;
}
P1253

 

 

18.P1905 忘了放哪里了qwq找到在贴上吧qwq

 

posted @ 2018-10-08 19:36  米罗偕涯  阅读(1882)  评论(1编辑  收藏  举报