#38483: 想請問為甚麼會超時,我的答案都是對的,是因為是一次輸入兩個單字而不是一次一整個字串嗎,請大神幫我解答,感謝


0402tim@gmail.com (江威廷)

學校 : 不指定學校
編號 : 134148
來源 : [39.10.65.253]
最後登入時間 :
2024-03-26 11:40:20
e269. 11220 - Decoding the message -- UVA | From: [140.117.248.1] | 發表日期 : 2023-11-29 12:39

#include <iostream>  
#include<string> 
#include<queue>  
using namespace std;
int main(){
 
int t;
cin>>t; getchar();getchar(); 
for(int i=0;i<t;i++){
char n='\0';
queue<string> q;
int f=1;
do{
 
 
string s,c;
int j=0;
do{
 
cin>>s;
if(n!='\0'){
s.insert(0,1,n);
n='\0';
}
if(j<s.size()){
c+=s[j];
j++;
}
}while(getchar()!='\n');
 
q.push(c);
 
n=getchar();
 
}while(n!='\n');
 
 
cout<<"Case #"<<i+1<<":"<<endl;
while(!q.empty()){
cout<<q.front()<<endl;
q.pop();
}
cout<<endl;
}
 
return 0;
}

 

 
ZeroJudge Forum