Submission #1097632

#TimeUsernameProblemLanguageResultExecution timeMemory
1097632FIFI_cppZagrade (COI20_zagrade)C++17
21 / 100
3068 ms344 KiB
#include <iostream> #include <vector> #include <algorithm> #include <numeric> #include <cstdlib> #include <cmath> #include <queue> #include <stack> #include <deque> #include <fstream> #include <iterator> #include <set> #include <map> #include <unordered_map> #include <iomanip> #include <cctype> #include <string> #include <cassert> #include <set> #include <bitset> #include <unordered_set> #include <numeric> using ll = int64_t; #define pb push_back #define all(a) a.begin(),a.end() #define ppi pair<int,pair<int,int>> #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); //#define int int64_t // xcode cant include bits/stdc++.h using namespace std; /* /\_/\ * (= ._.) * / > \> */ // encouraging cat //const int INF = 10000000000000000; //const int mod = 1000000007; const int mod = 1000000007; const int MAXN = 2003; //const int INF = 10000000000000000; //ifstream fin("fractii2.in"); //ofstream fout("fractii2.out"); map<pair<int,int>,bool> mp; bool valid_walk(int l,int r) { l++,r++; cout << "? " << l << " " << r << '\n'; cout.flush(); bool x; cin >> x; return x; } int32_t main() { int n,q; cin >> n >> q; vector<bool> del(n); auto kth_non_del = [&](int k) { for (int i = 0;i < n;i++) { if (del[i]) { continue; } if (k == 0) { return i; } k--; } return -1; }; string s; s.resize(n); int i = 0, d = 0; while (i < n - d - 1) { int a = kth_non_del(i), b = kth_non_del(i + 1); //cout << "? " << a + 1 << ' ' << b + 1 << endl; if (valid_walk(a, b)) { del[a] = del[b] = true; d += 2; s[a] = 'U'; s[b] = 'D'; if (i > 0) i--; } else { i++; } } int cnt = (n - d) / 2; for (int i = 0;i < n;i++) { if (del[i]) { continue; } if (cnt > 0) { s[i] = 'D'; cnt--; } else { s[i] = 'U'; } } cout << "! "; for (int i = 0;i < n;i++) { if (s[i] == 'U') cout << "("; else cout << ")"; } cout << '\n'; cout.flush(); return 0; }

Compilation message (stderr)

zagrade.cpp:31:9: warning: "/*" within comment [-Wcomment]
   31 | /*   /\_/\
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...