結果
| 問題 |
No.679 不思議マーケット
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-09-18 16:44:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 2,000 ms |
| コード長 | 1,132 bytes |
| コンパイル時間 | 1,762 ms |
| コンパイル使用メモリ | 174,920 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-18 08:01:41 |
| 合計ジャッジ時間 | 2,488 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;
const long long MOD = 1e9 + 7;
const long long INF = 5e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };
#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
int n, m, h, g, r, ans, rr[510];
map<int, vector<int>>mp;
bool b[510];
int main() {
cin >> n >> m;
for (int i = 0;i < m;i++) {
cin >> g >> r;
rr[g] = r;
for (int j = 0;j < r;j++) {
cin >> h;
mp[g].eb(h);
}
}
while (true) {
bool fl = 0;
for (int i = 1;i <= n;i++) {
if (b[i])continue;
if (mp[i].size() == 0) {
ans++;
b[i] = 1;
fl = 1;
}
else {
bool f = 0;
for (int j = 0;j < rr[i];j++) {
if (!b[mp[i][j]]) {
f = 1;
break;
}
}
if (!f) {
ans++;
b[i] = 1;
fl = 1;
}
}
}
if (!fl) {
cout << ans << endl;
return 0;
}
}
return 0;
}