結果

問題 No.679 不思議マーケット
ユーザー kotatsugamekotatsugame
提出日時 2018-04-27 22:48:25
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 608 ms
コンパイル使用メモリ 72,836 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-27 22:05:38
合計ジャッジ時間 1,310 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n,m;
vector<int>a[501];
bool ok[501];
main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int g,r;cin>>g>>r;
		ok[g]=1;
		for(;r--;)
		{
			int s;cin>>s;a[g].push_back(s);
		}
	}
	int cnt=0;
	for(int i=1;i<=n;i++)cnt+=!ok[i];
	for(int count=500;count--;)
	{
		for(int i=1;i<=n;i++)
		{
			if(!ok[i])continue;
			bool flag=1;
			for(int it:a[i])flag&=!ok[it];
			if(flag)
			{
				ok[i]=0;
				cnt++;
			}
		}
	}
	cout<<cnt<<endl;
}
0