P6994提供SPJ
  • 板块题目总版
  • 楼主ABlueCat
  • 当前回复3
  • 已保存回复3
  • 发布时间2022/8/30 11:48
  • 上次更新2023/10/27 13:06:37
查看原帖
P6994提供SPJ
60139
ABlueCat楼主2022/8/30 11:48

由于P6994没有讨论区,故发在题目总版:

#include "testlib.h"
#include <string>
#include <cstring>

int p[100];
int n;

inline int getint()
{
    int x = 0;
    char c = ouf.readChar();
    while (c > '9' || c < '0')
    {
        if (c == '\n' || c == '\r' || c == EOF)
        {
            return -1;
        }
        c = ouf.readChar();
    }
    while (c <= '9' && c >= '0')
    {
        x = x * 10 + c - '0';
        c = ouf.readChar();
    }
    return x;
}

int main(int argc, char* argv[])
{
    registerTestlibCmd(argc, argv);

    std::string a = "", b = "";

    a = inf.readString();

    while (1)
    {
        int c = getint();
        if (c == -1)
        {
            break;
        }
        if (c >= 100)
        {
            quitf(_wa, "Wrong Answer.");
            return 0;
        }
        p[c] = 1;
        b += std::to_string(c);
        n++;
    }

    for (int i = 1; i <= n; i++)
    {
        if (!p[i])
        {
            quitf(_wa, "Wrong Answer.");
            return 0;
        }
    }

    if (a == b)
    {
        quitf(_ok, "Accepted.");
    }
    else
    {
        quitf(_wa, "Wrong Answer.");
    }
    return 0;
}

@chen_zhe

2022/8/30 11:48
加载中...