답안 #1016831

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1016831 2024-07-08T13:05:54 Z 8pete8 Zagrade (COI20_zagrade) C++17
0 / 100
0 ms 344 KB
#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;
    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];
    cout<<endl;
}

Compilation message

zagrade.cpp:44:11: warning: multi-character character constant [-Wmultichar]
   44 |     cout<<'? '<<l<<" "<<r<<endl;
      |           ^~~~
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:48:14: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   48 | 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);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -