답안 #336133

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
336133 2020-12-14T19:46:38 Z bigDuck 게임 (IOI14_game) C++14
0 / 100
1 ms 384 KB
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#include "game.h"


multiset<int> g[1510];
int N;


void initialize(int n) {
N=n;
for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
        g[i].insert(j); g[j].insert(i);
    }
}



}


int v[1510];

int is_bridge(int x, int y, int ac){
int n=N;
queue<int> q1, q2;
v[x]=ac; v[y]=ac+1;
q1.push(x); q2.push(y);

while((!q1.empty()) && (!q2.empty()) ){
    int f1=q1.front(); q1.pop();
    //cout<<"f1: "<<f1<<" ";
    if( (v[f1]==(ac+1) )  ){
        g[x].erase(g[x].find(y)); g[y].erase(g[y].find(x) );
        //cout<<"\n"<<flush;


        return 0;
    }
    v[f1]=ac;
    for(auto it=g[f1].begin(); it!=g[f1].end(); it++){
        //cout<<*it<<" ";
        if( (v[*it]!=ac) && ( (*it)!=y) ){
            //cout<<*it<<"g1 ";
            q1.push(*it);
        }
    }
    //cout<<"2x\n";
    int f2=q2.front(); q2.pop();
    //cout<<"f2: "<<f2<<" ";
    if( (v[f2]==(ac) ) ){
        g[x].erase(g[x].find(y)); g[y].erase(g[y].find(x) );
       // cout<<"\n"<<flush;


        return 0;
    }
    v[f2]=ac+1;
    for(auto it=g[f2].begin(); it!=g[f2].end(); it++){
        //cout<<*it<<" ";
        if( (v[*it]!=(ac+1)) && ( (*it)!=x ) ){
            //cout<<*it<<"g ";
            q2.push(*it);
        }
    }

}

//cout<<"\n"<<flush;



return 1;
}




int ac=1;
int hasEdge(int u, int v) {
    ac+=3;
    return is_bridge(u, v, ac);
}

Compilation message

game.cpp: In function 'int is_bridge(int, int, int)':
game.cpp:34:5: warning: unused variable 'n' [-Wunused-variable]
   34 | int n=N;
      |     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -