Submission #640292

# Submission time Handle Problem Language Result Execution time Memory
640292 2022-09-14T05:59:58 Z makanhulia Zagrade (COI20_zagrade) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;
const ll maxn=1e5+5;
const int INF=1e9+5;
#define ok ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define endl '\n'
int bk, ttp, jwb, rem;
map<int, int> mp;
stack<int> st;
ll n, q;
int main() {
    ok
    cin >> n >> q;
    if(q==(n*n)/4) {
        rem=0;
        for(int i=1; i<n; i++) {
            for(int j=i+1; j<=n; j+=2) {
                cout << "? " << i << " " << j << endl;
                cout.flush();
                cin >> jwb;
                if(jwb==1) {
                    mp[i]=1;
                    mp[j]=2;
                }
            }
        }
        for(int i=1; i<=n; i++) {
            if(!mp.count(i)) {
                rem++;
            }
        }
        rem/=2;
        for(int i=1; i<=n; i++) {
            if(rem && !mp.count(i)) {
                mp[i]=2;
                rem--;
            } else if(!mp.count(i)) mp[i]=1;
        }
        cout << "! ";
        for(int i=1; i<=n; i++) {
            if(mp[i]==1) cout << '(';
            else cout << ')';
        }
        cout << endl;
        return 0;
    }
    for(int i=1; i<=n; i++) {
        if(st.empty()) {
            ans[i]='(';
            st.push(i);
            continue;
        }
        cout << "? " << st.top() << " " << i << endl;
        cout.flush();
        cin >> jwb;
        if(jwb==1) {
            ans[i]=')';
            st.pop();
        } else {
            ans[i]='(';
            st.push(i);
        }
    }
    cout << "! ";
    for(int i=1; i<=n; i++) {
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:60:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   60 |             ans[i]='(';
      |             ^~~
      |             abs
zagrade.cpp:68:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   68 |             ans[i]=')';
      |             ^~~
      |             abs
zagrade.cpp:71:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   71 |             ans[i]='(';
      |             ^~~
      |             abs
zagrade.cpp:77:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   77 |         cout << ans[i];
      |                 ^~~
      |                 abs