chore(judger/formatter): sync from uoj.ac

This commit is contained in:
Baoshuo Ren 2022-11-07 14:03:47 +08:00
parent eecd40efd8
commit 64603588bb
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -1,55 +1,32 @@
#include <cstdio> #include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include<cmath> #include <string>
#include<algorithm>
using namespace std; int main() {
typedef long long LL; int c = '?', last;
int main() std::string buf;
{ while (true) {
//freopen("1.in","r",stdin); last = c;
char c,last; c = getchar();
int nSpace=0,nR=0,first; if (c == EOF) {
while(1) if (last != '\n') {
{
last=c,c=getchar();
if(c==EOF)
{
if(last!='\n')
putchar('\n'); putchar('\n');
}
break; break;
} else if (c == ' ' || c == '\r') {
buf.push_back((char)c);
} else {
if (!buf.empty()) {
if (c != '\n') {
printf("%s", buf.c_str());
} }
else if(c!='\r'&&c!=' ') buf.clear();
{
if(c!='\n'&&first==0)
{
for(int j=1;j<=nSpace;++j)
putchar(' ');
for(int j=1;j<=nR;++j)
putchar('\r');
} }
else if(c!='\n')
{
for(int j=1;j<=nR;++j)
putchar('\r');
for(int j=1;j<=nSpace;++j)
putchar(' ');
}
nSpace=nR=0;
putchar(c); putchar(c);
} }
else if(c==' ')
{
++nSpace;
if(nR==0)
first=0;
}
else
{
++nR;
if(nSpace==0)
first=1;
}
} }
return 0; return 0;
} }