ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1109. Conference

JamesBond_007 Why WA4? [3] // Problem 1109. Conference 25 Oct 2016 14:22
#include <iostream>
#include <vector>
#include <set>
using namespace std;
set < pair <int, int> > S;
set < pair <int, int> > :: iterator it;
vector <int> A[1111], B[1111];
int n, k, m, x[1111], y[1111], res, X[1111], Y[1111];
bool used[111111];
void cut_x(int v){
    for (int i = 0; i < k; i ++){
        if(!used[i] && X[i] == v && y[Y[i]] > 1){used[i] = true; y[Y[i]] --; res --;}
    }
}
void cut_y(int v){
    for (int i = 0; i < k; i ++){
        if(!used[i] && Y[i] == v && x[X[i]] > 1){used[i] = true; x[X[i]] --; res --;}
    }
}
int main(){
    cin >> n >> m >> k;
    res = k;
    for (int i = 0; i < k; i ++){
        int u, v;
        cin >> X[i] >> Y[i];
        A[X[i]].push_back(Y[i]);
        B[Y[i]].push_back(X[i]);
        x[X[i]] ++; y[Y[i]] ++;
    }
    for (int i = 1; i <= n; i ++)
        S.insert(make_pair(x[i], i));
    for (it = S.begin(); it != S.end(); it ++){
        pair <int, int> v = *it;
        if(v.first == 1){
            cut_y(A[v.second][0]);
        }else{
            cut_x(v.second);
        }
    }
    cout << res;
}
JamesBond_007 Re: Why WA4? [1] // Problem 1109. Conference 25 Oct 2016 14:23
Help me?
Freopen Re: Why WA4? // Problem 1109. Conference 18 Apr 2017 10:20
Bipartite graph
Husayn Hasanov Re: Why WA4? // Problem 1109. Conference 8 Dec 2017 16:23
Your idea has bug you have to think again clearly!