結果
| 問題 | No.679 不思議マーケット |
| コンテスト | |
| ユーザー |
i_mrhj
|
| 提出日時 | 2020-03-26 13:26:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 988 bytes |
| 記録 | |
| コンパイル時間 | 646 ms |
| コンパイル使用メモリ | 45,568 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-01-02 01:26:13 |
| 合計ジャッジ時間 | 1,382 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | scanf("%d %d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%d %d", &g, &r);
| ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:12:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d", &x);
| ~~~~~^~~~~~~~~~
ソースコード
#include <cstdio>
#include <vector>
using namespace std;
int main(void) {
int n, m, g, r, x;
vector<int> h[550];
scanf("%d %d", &n, &m);
for (int i = 0; i < m; i++) {
scanf("%d %d", &g, &r);
for (int j = 0; j < r; j++) {
scanf("%d", &x);
h[g - 1].push_back(x - 1);
}
}
bool ch[550] = {};
for (int i = 0; i < n; i++) {
if (h[i].empty()) ch[i] = true;
}
bool rp = true, f;
while (rp) {
rp = false;
for (int i = 0; i < n; i++) {
f = true;
if (h[i].empty()) continue;
for (int j = 0; j < h[i].size(); j++) {
if (!ch[h[i][j]]) f = false;
if (!f) break;
}
if (f) {
ch[i] = true;
h[i].clear();
rp = true;
}
}
}
int ans = 0;
for (int i = 0; i < n; i++) if (ch[i]) ans++;
printf("%d\n", ans);
return 0;
}
i_mrhj