Submission #1016834

#TimeUsernameProblemLanguageResultExecution timeMemory
10168348pete8Zagrade (COI20_zagrade)C++17
100 / 100
605 ms2012 KiB
#include<iostream> #include<stack> #include<map> #include<vector> #include<string> #include<cassert> #include<unordered_map> #include <queue> #include <cstdint> #include<cstring> #include<limits.h> #include<cmath> #include<set> #include<algorithm> #include <iomanip> #include<numeric> #include<bitset> using namespace std; #define ll long long #define f first #define s second #define pii pair<int,int> #define ppii pair<int,pii> #define vi vector<int> #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define F(n) for(int i=0;i<n;i++) #define lb lower_bound #define ub upper_bound #define fastio ios::sync_with_stdio(false);cin.tie(NULL); #pragma GCC optimize ("03,unroll-lopps") #define int long long using namespace std; const int mod=1e9+7,mxn=2e5+5,inf=1e18,minf=-1e18,lg=30; //#undef int int n,k,m,q; void setIO(string name){ ios_base::sync_with_stdio(0); cin.tie(0); freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } int ask(int l,int r){ cout<<"? "<<l<<" "<<r<<endl; cout.flush(); int x;cin>>x; return x; } int32_t main(){ fastio cin>>n>>q; stack<int>st; vector<char>ans(n+1,'?'); int cnt=0; for(int i=1;i<=n;i++){ if(st.empty())st.push(i); else{ if(ask(st.top(),i))ans[st.top()]='(',ans[i]=')',st.pop(),cnt+=2; else st.push(i); } } cnt=n-cnt; cnt/=2; for(int i=1;i<=n;i++){ if(ans[i]=='?'){ if(cnt)ans[i]=')',cnt--; else ans[i]='('; } } cout<<"! "; for(int i=1;i<=n;i++)cout<<ans[i]; }

Compilation message (stderr)

zagrade.cpp:32:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
   32 | #pragma GCC optimize ("03,unroll-lopps")
      |                                        ^
zagrade.cpp:38:23: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   38 | void setIO(string name){
      |                       ^
zagrade.cpp:43:20: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   43 | int ask(int l,int r){
      |                    ^
zagrade.cpp:49:14: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   49 | int32_t main(){
      |              ^
zagrade.cpp: In function 'void setIO(std::string)':
zagrade.cpp:40:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
zagrade.cpp:41:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...