結果
| 問題 |
No.241 出席番号(1)
|
| ユーザー |
nasadigital
|
| 提出日時 | 2015-07-10 22:56:30 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
MLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,317 bytes |
| コンパイル時間 | 650 ms |
| コンパイル使用メモリ | 67,888 KB |
| 実行使用メモリ | 814,516 KB |
| 最終ジャッジ日時 | 2024-07-08 02:04:09 |
| 合計ジャッジ時間 | 3,485 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | MLE * 1 -- * 28 |
ソースコード
#include <iostream>
#include <cstring>
#include <queue>
#include <vector>
#include <utility>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> VI;
typedef vector<VI> VVI;
bool FindMatch(int i, const VVI &w, VI &mr, VI &mc, VI &seen) {
for (int j = 0; j < w[i].size(); j++) {
if (w[i][j] && !seen[j]) {
seen[j] = true;
if (mc[j] < 0 || FindMatch(mc[j], w, mr, mc, seen)) {
mr[i] = j;
mc[j] = i;
return true;
}
}
}
return false;
}
int BipartiteMatching(const VVI &w, VI &mr, VI &mc) {
mr = VI(w.size(), -1);
mc = VI(w[0].size(), -1);
int ct = 0;
for (int i = 0; i < w.size(); i++) {
VI seen(w[0].size());
if (FindMatch(i, w, mr, mc, seen)) ct++;
}
return ct;
}
int main(int argc, const char * argv[])
{
int n;
cin>>n;
VVI f;
for(int ctr1=0;ctr1<n;ctr1++){
VI t(n,1);
f.push_back(t);
}
for(int ctr1=0;ctr1<n;ctr1++){
int a;
cin>>a;
f[ctr1][a]=0;
}
VI rez,rez2;
int r=BipartiteMatching(f, rez, rez2);
if(r!=n){
cout<<-1;
}
else{
for(int ctr1=0;ctr1<n;ctr1++){
cout<<rez[ctr1]<<endl;
}
}
return 0;
}
nasadigital