Submission #239217

# Submission time Handle Problem Language Result Execution time Memory
239217 2020-06-14T20:19:56 Z osaaateiasavtnl Teleporters (IOI08_teleporters) C++14
0 / 100
903 ms 7748 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define str to_string

mt19937 rnd(228);

const int TEST = 10000;

string read(string name) {
    string ans;
    string line;
    ifstream t(name);
    while (getline(t, line)) ans += line + '\n';
    return ans;
}

/*
const int C = 3;
string genstring(int n) {
    string ans;
    for (int i = 0; i < n; ++i) {
        ans += (char)('a' + rnd() % C);
    }   
    return ans;
}
*/


string tree(int n) {
    string ans;
    for (int i = 1; i < n; ++i) {
        ans += to_string(rnd() % i + 1) + ' ' + to_string(i + 1) + '\n';
    }   
    return ans;
}   

string perm(int n) {
    string ans;
    vector <int> p(n);
    for (int i = 0; i < n; ++i) p[i] = i;
    shuffle(p.begin(), p.end(), rnd);
    for (int e : p) ans += str(e + 1) + ' ';
    return ans;
}   

int lcm(int a, int b) {
    return a * b / __gcd(a, b);
}   

string gen() {
    string test;        
    
    int t = 1;
    while (t--) {   
        int n = rnd() % 3 + 1;               
        int m = rnd() % 2 + 1;

        test += str(n) + ' ' + str(m) + '\n';

        vector <int> c;
        for (int i = 1; i <= 2 * n; ++i)
            c.app(i);
        shuffle(all(c), rnd);
        for (int i = 0; i < n; ++i) {
            int l = c[2 * i];
            int r = c[2 * i + 1];
            if (r < l)  
                swap(l, r);
            test += str(l) + ' ' + str(r) + '\n';
        }           

    }

    return test;
}

signed main() {
    ofstream ans("test.txt");

    system("g++ -O2 -std=gnu++17 main.cpp -o main.exe");
    system("g++ -O2 -std=gnu++17 brute.cpp -o brute.exe");

    for (int i = 0; i < TEST; ++i) {
        string test = gen();

        ofstream newtest("newtest.txt");
        newtest << test;
        newtest.close();

        system("main.exe < newtest.txt > out1.txt");
        system("brute.exe < newtest.txt > out2.txt");

        string ans1 = read("out1.txt");
        string ans2 = read("out2.txt");
        
        if (ans1 != ans2 && ans1 + '\n' != ans2 && ans2 + '\n' != ans1) {
            ans << test;
            ans.close();
            exit(0);
        }

        cout << i << '\n';
    }

    cout << "NOT FOUND\n";
    ans.close();
    return 0;
}

Compilation message

teleporters.cpp: In function 'int main()':
teleporters.cpp:92:11: warning: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result [-Wunused-result]
     system("g++ -O2 -std=gnu++17 main.cpp -o main.exe");
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
teleporters.cpp:93:11: warning: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result [-Wunused-result]
     system("g++ -O2 -std=gnu++17 brute.cpp -o brute.exe");
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
teleporters.cpp:102:15: warning: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result [-Wunused-result]
         system("main.exe < newtest.txt > out1.txt");
         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
teleporters.cpp:103:15: warning: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result [-Wunused-result]
         system("brute.exe < newtest.txt > out2.txt");
         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 887 ms 5984 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 900 ms 6168 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 877 ms 7748 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 869 ms 5468 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 881 ms 7620 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 890 ms 5936 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 873 ms 6556 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 888 ms 5932 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 885 ms 5924 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 876 ms 5740 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 883 ms 6080 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 891 ms 5636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 884 ms 6616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 895 ms 6292 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 892 ms 5056 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 896 ms 4900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 889 ms 5696 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 890 ms 6644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 888 ms 6568 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 903 ms 6380 KB Output isn't correct
2 Halted 0 ms 0 KB -