Submission #804425

# Submission time Handle Problem Language Result Execution time Memory
804425 2023-08-03T08:39:34 Z Tunglam07 Naboj (COCI22_naboj) C++17
0 / 110
232 ms 10008 KB
#include <bits/stdc++.h>
using namespace std;
 
vector<long long> vec[200005], ans;
long long m ,n ,dp[200005];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> m >> n;
	queue<long long> q;
	while(n--);
	{
		long long a ,b;
		cin >> a >> b;
		vec[a].push_back(b);
		dp[b]++;
	} 
	for(int i=1;i<=m;i++)
	{
		if(dp[i]==0) 
		{
			q.push(i);
		}
	}
	while(!q.empty())
  	{
    	long long id = q.front();
    	q.pop();
    	ans.push_back(id);
    	for(long long nx:vec[id])
		{
    		dp[nx]--;
    		if(dp[nx]==0) 
			{
		  		q.push(nx);
			}
    	}
  	}
	if(ans.size()!=m) 
  	{
  		cout << -1;
  	}
  	else 
	{
   		cout << ans.size() <<endl;
    	for(long long nx:ans)
		{
    		cout << nx << " " << 0 << endl;
    	}
  	}
}

Compilation message

naboj.cpp: In function 'int main()':
naboj.cpp:14:2: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   14 |  while(n--);
      |  ^~~~~
naboj.cpp:15:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   15 |  {
      |  ^
naboj.cpp:42:15: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   42 |  if(ans.size()!=m)
      |     ~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 5000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 232 ms 10008 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 5000 KB Output isn't correct
2 Halted 0 ms 0 KB -