Submission #780824

# Submission time Handle Problem Language Result Execution time Memory
780824 2023-07-12T13:37:07 Z kebine Zagrade (COI20_zagrade) C++17
100 / 100
807 ms 1540 KB
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL jawab;
void tanya(LL x,LL y)
{
  cout<<"? "<<x<<" "<<y<<endl;
  cin>>jawab;
}
int main()
{
  LL n,q;
  scanf("%lld %lld",&n,&q);
  vector<LL>v;
  char arr[n+5];
  for(LL a=1;a<=n;a++)
  {
    arr[a]='*';
  }
  LL buka=0,tutup=0;
  for(LL a=1;a<=n;a++)
  {
    if(v.size()==0)
    {
      v.push_back(a);
      continue;  
    }
    tanya(v[v.size()-1],a);
    if(!jawab)
    {
      v.push_back(a);
    }
    else
    {
      arr[v[v.size()-1]]='(';
      arr[a]=')';
      tutup++;
      v.pop_back();
    }
  }
  LL bagi=n/2;
  for(LL a=1;a<=n;a++)
  {
  //  printf("%lld %lld %lld\n",buka,tutup,bagi);
    if(arr[a]=='*')
    {
      if(tutup<bagi)
      {
        arr[a]=')';
        tutup++;
      }
      else arr[a]='(';
    }
  }
  cout<<"! ";
  for(LL a=1;a<=n;a++)cout<<arr[a];
  cout<<endl;
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:20:6: warning: unused variable 'buka' [-Wunused-variable]
   20 |   LL buka=0,tutup=0;
      |      ^~~~
zagrade.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%lld %lld",&n,&q);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 5 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 9 ms 208 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 9 ms 208 KB Output is correct
7 Correct 6 ms 208 KB Output is correct
8 Correct 4 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 9 ms 312 KB Output is correct
5 Correct 5 ms 296 KB Output is correct
6 Correct 6 ms 300 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
8 Correct 6 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 373 ms 336 KB Output is correct
3 Correct 672 ms 336 KB Output is correct
4 Correct 625 ms 336 KB Output is correct
5 Correct 707 ms 372 KB Output is correct
6 Correct 635 ms 336 KB Output is correct
7 Correct 655 ms 1024 KB Output is correct
8 Correct 610 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 681 ms 1540 KB Output is correct
3 Correct 688 ms 800 KB Output is correct
4 Correct 741 ms 968 KB Output is correct
5 Correct 807 ms 764 KB Output is correct
6 Correct 703 ms 948 KB Output is correct
7 Correct 611 ms 732 KB Output is correct
8 Correct 704 ms 380 KB Output is correct