Skip to content
Discussion options

You must be logged in to vote

We use testlib for standard I/O interaction. For function interaction, you can try to #include "grader.cpp".

Click to expand the example of I/O interaction
// source.cpp
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int l = 1, r = 1000000000;
    while (true)
    {
        int mid = l + (r - l) / 2;
        cout << mid << endl;
        cout.flush();
        int res;
        cin >> res;
        if (res == 0)
            break;
        else if (res == -1)
            l = mid + 1;
        else
            r = mid - 1;
    }
    return 0;
}
// spj.cpp
#include "testlib.h"
using namespace std;
int main(int argc, char **argv)
{
    registerInteraction(argc, argv);
    int n …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by langningchen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants