Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

致所有莫名其妙WA掉的OIer

Posted by Echidna at 2021-05-23 16:14:09 on Problem 1026
您可能没读懂这个题的恶心输入输出方式。

这个题的输入数据包括多个“block”,t=0 时标志着一个block的结束,n=0时标志着这个这个题的数据的结束。

这个题的数据不存在 s 中包括换行。

另外发一发自己的400ms快速幂做法

#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
struct Group{
    int x[250];
};
int n;
Group mul(Group a,Group b){
    for(int i=1;i<=n;i++){
        a.x[i]=b.x[a.x[i]];
    }
    return a;
}
Group pow(Group a,int x){
    if(x==1){
        return a;
    }
    if(x%2==0){
        Group temp=pow(a,x/2);
        return mul(temp,temp);
    }else{
        return mul(a,pow(a,x-1));
    }
}
Group gr;
char resu[1000];
int solve(){
    cin>>n;
    if(n==0){
        return 0;
    }
    for(int i=1;i<=n;i++){
        cin>>gr.x[i];
    }
    int t;
    string s;
    while(1){
        cin>>t;
        getline(cin,s);
        if(t==0){
            cout<<endl;
            return 1;
        }
        Group res=pow(gr,t);
        for(int i=1;i<=n;i++){
            if(i<s.length())
                resu[res.x[i]]=s[i];
            else resu[res.x[i]]=' ';
        }
        for(int i=1;i<=n;i++)
            cout<<resu[i];
        cout<<endl;
    }
}
int main(){
    while(solve());
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator