Div2 A求调
  • 板块学术版
  • 楼主Masdsasa
  • 当前回复9
  • 已保存回复9
  • 发布时间2023/1/24 18:17
  • 上次更新2023/10/24 03:11:09
查看原帖
Div2 A求调
728122
Masdsasa楼主2023/1/24 18:17

全WA

#include <iostream>
#include <string>
#include <cmath>
#define normal "PION2202 RP++."
#define zuzong "Wrong file operation takes you to your ancestors along with your 3 years' efforts on OI."
#define le "Good luck and have fun."
using namespace std;
string prob[10], tm, base_str_in = R"(freopen("title.in","r",stdin);)", base_str_out = R"(freopen("title.out","w",stdout);)", new_str; // 原始字符串 如R"(xxxx)"
int t, n, m;

void initStr(int j)
{
    int ind = j / 2;
    // cout << "ind" << ind << endl;
    if (j % 2 == 0)
        new_str = base_str_in.replace(base_str_in.find('"') + 1, 5, prob[ind]);
    else
        new_str = base_str_out.replace(base_str_out.find('"') + 1, 5, prob[ind]);
    base_str_in = R"(freopen("title.in","r",stdin);)", base_str_out = R"(freopen("title.out","w",stdout);)";
}

bool check()
{
    if (tm.substr(0, 2) == "//")
        return 1;
    if (tm.size() != new_str.size())
        return 1;
    for (int i = 0; i < tm.size(); i++)
    {
        if (tm[i] != new_str[i])
            return 1;
    }
    return 0;
}

int main()
{
    cin >> t >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> prob[i];
    }
    for (int i = 0; i < n; i++)
    {
        bool n = true;
        for (int j = 0; j < 2 * m; j++)
        {
            cin >> tm;
            if (tm.substr(0, 10) == "//freopen(" && tm.substr(tm.size() - 2, 2) == ");")
            {
                cout << zuzong << endl;
                n = 0;
                break;
            }
            initStr(j);
            // cout << new_str << endl;
            // cout << tm << endl
            //      << endl;
            if (check())
            {
                cout << le << endl;
                n = 0;
                break;
            }
        }
        if (n)
            cout << normal << endl;
    }

    return 0;
}

2023/1/24 18:17
加载中...