답안 #944666

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
944666 2024-03-13T02:50:27 Z yeediot Minerals (JOI19_minerals) C++17
0 / 100
1 ms 600 KB
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pb push_back
#define sz(x) (int)(x.size())
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define vi vector<int>
#define vp vector<pii>
#define vvi vector<vi>
const int mxn=43000;

#ifdef local
void setio(){freopen("/Users/iantsai/Library/Mobile Documents/com~apple~CloudDocs/cpp/Empty.md","r",stdin);}
set<int>cur;
int color[mxn];
int cnt[mxn];
int n;
bool ok;
int tt=0;
void init(){
    cin>>n;
    for(int i=1;i<=2*n;i++){
        cin>>color[i];
    }
}
int Query(int x){
    tt++;
    if(cur.find(x)!=cur.end()){
        cur.erase(x);
        cnt[color[x]]--;
    }
    else{
        cur.insert(x);
        cnt[color[x]]++;
    }
    return cnt[color[x]];
}
void Answer(int a,int b){
    if(a>b)swap(a,b);
    cout<<a<<' '<<b<<'\n';
    if(color[a]!=color[b]){
        ok=0;
    }
}
#else
void setio(){}
#include "minerals.h"
#endif
//////////////////
void dac(vector<int>cur,int l,int r){
    if(l==r){
        Answer(cur[0],l);
        return;
    }
    int mm=l+r>>1;
    for(int i=l;i<=mm;i++){
        Query(i);
    }
    vector<int>L,R;
    for(auto i:cur){
        int x=Query(i);
        if(x==2){
            L.pb(i);
        }
        else{
            R.pb(i);
        }
        Query(i);
    }
    for(int i=l;i<=mm;i++){
        Query(i);
    }
    dac(L,l,mm);
    dac(R,mm+1,r);
}
void Solve(int n){
    vector<int>temp;
    for(int i=1;i<=n;i++){
        temp.pb(i);
    }
    dac(temp,n+1,n+n);
}
/////////////////
#ifdef local
int main(){
    ok=1;
    tt=0;
    setio();
    init();
    Solve(n);
    cout<<tt<<'\n';
    if(ok)cout<<"Accepted!\n";
    else cout<<"Wrong Answer\n";
}
#else

#endif

 /*
 input:
 
 */















 

Compilation message

minerals.cpp: In function 'void dac(std::vector<int>, int, int)':
minerals.cpp:59:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   59 |     int mm=l+r>>1;
      |            ~^~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -