https://icpcarchive.ecs.baylor.edu/external/64/6481.pdf
把该字符串转化为给定格式,‘;’在第几行就是第几秒。
但有好多坑,样例组数后可能有空格。数据中:后可能没空格,要你自己加
代码:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<set>
#include<cstring>
#include<algorithm>
#define LL long long
#define MOD 100000007
#define INF 0x3f3f3f3f
using namespace std;
const int maxn=305;
queue<char >q;
int cnt,num;
void print()
{
printf("%d: ",num);
int x=0;
while(!q.empty())
{
x++;
char c=q.front();q.pop();
if(x==3&&c=='Z')printf(" Z");
else if(c==':')printf(": ");
else putchar(c);
}
printf(";\n");
}
int main()
{
int T;char ss[10000];
scanf("%d",&T);gets(ss);
while(T--)
{
while(!q.empty())
q.pop();
cnt=0;num=0;
while(gets(ss))
{
++num;
if(!strcmp(ss,"END OF CASE"))break;
int t=strlen(ss);
for(int i=0;i<t;i++)
if(ss[i]==' ')continue;
else if(ss[i]!=';')
{
q.push(ss[i]);
}
else
{
print();
}
}
}
return 0;
}