求助 无输出 TLE

P5730 【深基5.例10】显示屏

LeNotFound @ 2022-05-25 11:21:04

维护了五个字付串分别表示每一行的答案
然后每个数字都是对五行字符串后添加内容
维护一个队列表示要输出的数字
每次从队首取一位判断并将对应字符串添加进入line字符串
编译能通过 但是没有输出 求助各位大佬

#include <bits/stdc++.h>

using namespace std;

inline int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
        {
            f = -1;
        }
        ch = getchar();
    }
    while (isdigit(ch))
    {
        x = (x << 1) + (x << 3) + (ch ^ 48);
        ch = getchar();
    }
    return x * f;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

ll n;
queue<ll> a;

string line1;
string line2;
string line3;
string line4;
string line5;

void p0()
{
    line1 += "XXX";
    line2 += "X.X";
    line3 += "X.X";
    line4 += "X.X";
    line5 += "XXX";
}

void p1()
{
    line1 += "..X";
    line2 += "..X";
    line3 += "..X";
    line4 += "..X";
    line5 += "..X";
}

void p2()
{
    line1 += "XXX";
    line2 += "..X";
    line3 += "XXX";
    line4 += "X..";
    line5 += "XXX";
}

void p3()
{
    line1 += "XXX";
    line2 += "..X";
    line3 += "XXX";
    line4 += "..X";
    line4 += "XXX";
}

void p4()
{
    line1 += "X.X";
    line2 += "X.X";
    line3 += "XXX";
    line4 += "..X";
    line5 += "..X";
}

void p5()
{
    line1 += "XXX";
    line2 += "X..";
    line3 += "XXX";
    line4 += "..X";
    line5 += "XXX";
}

void p6()
{
    line1 += "XXX";
    line2 += "X..";
    line3 += "XXX";
    line4 += "X.X";
    line5 += "XXX";
}

void p7()
{
    line1 += "XXX";
    line2 += "..x";
    line3 += "..X";
    line4 += "..X";
    line5 += "..X";
}

void p8()
{
    line1 += "XXX";
    line2 += "X.X";
    line3 += "XXX";
    line4 += "X.X";
    line5 += "XXX";
}

void p9()
{
    line1 += "XXX";
    line2 += "X.X";
    line3 += "XXX";
    line4 += "..X";
    line5 += "XXX";
}

void part()
{
    line1 += ".";
    line2 += ".";
    line3 += ".";
    line4 += ".";
    line5 += ".";
}

int main()
{
    n = read();
    for (ll i = 0; i < n; i++)
    {
        a.push(read());
    }

    while (!a.empty())
    {
        if(a.front()==0)
        {
            p0();
            part();
        }
        else if(a.front()==1)
        {
            p1();
            part();
        }
        else if(a.front()==2)
        {
            p2();
            part();
        }
        else if(a.front()==3)
        {
            p3();
            part();
        }
        else if(a.front()==4)
        {
            p4();
            part();
        }
        else if(a.front()==5)
        {
            p5();
            part();
        }
        else if(a.front()==6)
        {
            p6();
            part();
        }
        else if(a.front()==7)
        {
            p7();
            part();
        }
        else if(a.front()==8)
        {
            p8();
            part();
        }
        else if(a.front()==9)
        {
            p9();
            part();
        }
        a.pop();
    }

    line1.pop_back();
    line2.pop_back();
    line3.pop_back();
    line4.pop_back();
    line5.pop_back();

    cout << line1 << endl;
    cout << line2 << endl;
    cout << line3 << endl;
    cout << line4 << endl;
    cout << line5 << endl;

    // Debug
    // int Debuger=0;
    // cin>>Debuger;
    return 0;
}

by BartonTianjin @ 2022-05-27 11:34:02

这是什么游戏,超级码力吗


by hhtl @ 2022-05-27 11:40:14

为啥最后pop_back()


by hhtl @ 2022-05-27 11:41:07

把pop_back()删了@LeNotFound


by Karl_Aurora @ 2022-05-27 11:53:45

@hhtl pop_back是删去多加的一个.


by Karl_Aurora @ 2022-05-27 11:54:37

@LeNotFound 感觉主程序没什么问题,是不是快读的锅啊(


by Karl_Aurora @ 2022-05-27 12:00:03

@LeNotFound 把快读改成cin后变成了WA,证明是快读的锅


by LeNotFound @ 2022-05-27 12:03:35

@hhtl

@hhtl pop_back是删去多加的一个.吧

正解,最后多加了一列.


by LeNotFound @ 2022-05-27 12:07:16

@Karl_Aurora WA返回的是too short on line1说明还是没有输出啊


by LeNotFound @ 2022-05-27 12:23:06

@Karl_Aurora 确实是读入的锅 我没有按位划分


by LeNotFound @ 2022-05-27 12:29:09

此贴完结


|