Submission #1152415

#TimeUsernameProblemLanguageResultExecution timeMemory
1152415justin271828Zagrade (COI20_zagrade)C++20
0 / 100
0 ms408 KiB
#include <bits/stdc++.h> using namespace std; int main() { int N, Q; cin >> N >> Q; char arr[N+5]; memset(arr, 'a', sizeof(arr)); int start = 1; int end = 2; int count = N/2; while (end <= N) { int ans; cout << "\n? " << start << " " << end; cin >> ans; if (ans == 1) { count--; arr[start] = '('; arr[end] = ')'; if (start > 1 && arr[start-1] == 'a') { start--; end++;} else { start = end+1; end = start+1;} } else { start = end; end = start+1; } } int temp = 0; int index = 1; while (temp < count) { if (arr[index] == 'a') { arr[index] = ')'; temp++; } index++; } temp = 0; while (temp < count) { if (arr[index] == 'a') { arr[index] = '('; temp++; } index++; } cout << "\n! "; for (int i = 1; i <= N; i++) cout << arr[i]; return 0;}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...