Flavanoid's blog

By Flavanoid, history, 2 years ago, In English

Here is my code. When compiling using g++ 12.1.0 on my local machine or using GNU G++ 20 on the judging machine, it always stop the input after the first loop of the first loop. Like it showns here. With the debug code, it output something like this where lines start with > is my input.

But when compiling with Clang++ on my local machine or on judge machine, it works well.

P.S. please ignore the WA on clang++, it is caused by making too many queries, which can be solved using binary search but I've not implement that yet.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By Flavanoid, history, 2 years ago, In English

Here is my code. When compiling using g++ 12.1.0 on my local machine or using GNU G++ 20 on the judging machine, it always stop the input after the first loop of the first loop. Like it showns here. With the debug code below, it output something like 5 ? 1 1 > g 1- ? 2 1 2 > 2 ? 1 2 > u 1- ! gu??? where lines start with > is my input.

But when compiling with Clang++ on my local machine or on judge machine, it works well.

P.S. please ignore the WA on clang++, it is caused by making too many queries, which can be solved using binary search but I've not implement that yet.

Dbg Code: ```

include <bits/stdc++.h>

using namespace std;

define endl "\n"

pragma GCC optimize(3, "Ofast", "inline")

typedef vector vi; const int INF = 2e9;

define yesnosolve cout << (solve() ? "NO" : "YES") << endl

char q1(int pos) { char c; cout << "? 1 " << pos + 1 << endl << flush; scanf("%s", &c); return c; }

int q2(int pos1, int pos2) { int ans; cout << "? 2 " << pos1 + 1 << ' ' << pos2 + 1 << endl << flush; cin >> ans; return ans; }

void solve() { int len; cin >> len; vector res(len, '?');

res[0] = q1(0);
// cerr << res[0] << endl
//      << flush;
// cerr << len << '-' << endl;
for (int i = 1; i < len; i++)
{
    cerr << i << '-' << endl;
    set<char> st;
    bool f = false;
    for (int j = i - 1; j >= 0; j--)
    {
        st.insert(res[j]);
        if (q2(j, i) == int(st.size()))
        {
            res[i] = res[j];
            f = true;
            break;
        }
    }

    if (!f)
        res[i] = q1(i);

    cerr << i << '-' << endl;
}

cout << "! ";
for (auto &a : res)
    cout << a;
cout << endl
     << flush;

}

int main() { // cin.tie(nullptr); // cout.tie(nullptr); // ios_base::sync_with_stdio(0);

// int T;
// cin >> T;
// while (T--)
solve();

return 0;

} ```

Full text and comments »

  • Vote: I like it
  • -6
  • Vote: I do not like it