random & spj

Laffey 2022-10-24 13:52:27

random

#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <random>
using namespace std;

string itos(int x)
{
    string ans;
    while (x) {
        ans += x % 10UL + '0';
        x /= 10;
    }
    reverse(ans.begin(), ans.end());
    return ans;
}

mt19937 random(1145141919810);
const int ns[] = {1, 2, 2, 3, 3, 4, 4, 5, 6, 7, 8, 9, 10, 10, 10, 12, 12, 12, 12, 12};
const int ms[] = {1, 1, 2, 4, 1, 2, 3, 3, 1, 3, 2, 4, 5, 4, 5, 4, 2, 4, 5, 5};
const int mods[] = {10, 100, 100, 100, 1000, 10000, 100000, 100000, 1000000, 10000000, 100000000, 100000000, 100000000, 100000000, 100000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000};

int rand_int()
{
    return (random() & 1) ? random() : -random();
}

int main()
{
    for (int cnt = 1; cnt <= 20; cnt++) {
        string in = itos(cnt) + ".in";
        string ans = itos(cnt) + ".ans";

        ofstream fout(in, ios_base::out);
        fout << ns[cnt - 1] << ' ' << ms[cnt - 1] << '\n';
        for (int i = 1; i <= ns[cnt - 1] + ms[cnt - 1]; i++) {
            fout << rand_int() % mods[cnt - 1] << ' ' << rand_int() % mods[cnt - 1] << '\n';
        }
        fout.close();

        freopen(in.c_str(), "r", stdin);
        freopen(ans.c_str(), "w", stdout);
        system("std.exe");
    }
}

spj

#include <iostream>
#include <fstream>
using namespace std;

int main()
{
    ifstream out("user_out", ios_base::in);
    ifstream ans("answer", ios_base::in);
    double ans1, ans2;
    out >> ans1;
    ans >> ans2;
    if (ans1 - ans2 <= 1e-6) {
        cout << 100;
        cerr << "awa";
        return 0;
    }
    cout << 0;
    cerr << "ewe";
    return 0;
}