Блог пользователя Mahfuz2411

Автор Mahfuz2411, история, 7 часов назад, По-английски

Contest: Codeforces Round 967 (Div. 2) Problem: 2001C - Guess The Tree

Please read my post, and if you don't like it, before downvoting, please leave a comment explaining why you didn't like my post!

I haven't dealt with this type of problem before, so I don't know what's happening here. Please help me.

here is my code

void solve() {
    int n;   cin>>n;
    vector <int> v[1001];
    vector <pair <int,int>> ans;
    for(int i=2; i<=n; i++) {
        cout << "? " << 1 << ' ' << i << endl;
        cout.flush();
        int a;  cin>>a;
        if(a==1) ans.push_back({1, i});
        else v[a].push_back(i);
    }
 
    for(int i=2; i<=n; i++) {
        for(auto j: v[i]) {
            cout << "? " << i << ' ' << j << endl;
            cout.flush();
          
            int a;  cin>>a;
            if(a==-1) exit(0);
            if(a==i or a==j) ans.push_back({i, j});
            else v[a].push_back(j);
        }
    }
 
    cout << "! ";
    for(auto [x,y]: ans) cout << x << ' ' << y << spc;
    cout << newl;
    cout.flush();
    // long_line;
    return;
}

and here is my submission

Полный текст и комментарии »

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

Автор Mahfuz2411, история, 17 месяцев назад, По-английски

Problem : 86D - Powerful array My submission: 193616090

I don't understand what I'm doing wrong here?

This problem can be solved using Moss algorithm. So I was trying to solve this with moss algorithm but still time limit for test case no 6.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -1
  • Проголосовать: не нравится