답안 #1078834

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078834 2024-08-28T06:50:12 Z Faisal_Saqib 식물 비교 (IOI20_plants) C++17
0 / 100
3 ms 5204 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
const int N=200100;
int cp[N],od[N],deg[N];
vector<int> ma[N];
void init(int k, std::vector<int> r) {
	int n=r.size();
	for(int i=0;i<n;i++)
	{
		int j=(i+1)%n;
		if(r[i]==0)
		{
			// j -> i
			deg[i]++;
			ma[j].push_back(i);
		}
		else
		{
			// i -> j
			deg[j]++;
			ma[i].push_back(j);
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(deg[i]==0 and cp[i]==0)
		{
			cnt++;
			queue<int> cur;
			cur.push(i);
			int jp=0;
			while(cur.size()>0)
			{
				int f=cur.front();
				cur.pop();
				cp[f]=cnt;
				od[f]=jp;
				jp++;
				for(auto s:ma[f])
				{
					deg[s]--;
					if(deg[s]==0)
						cur.push(s);
				}
			}
		}
	}
	return;
}
 
int compare_plants(int x, int y) {
	if(cp[x]==cp[y])
	{
		if(od[x]==od[y])return 0;
		return ((od[x]<od[y])?-1:1);
	}
	else
		return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 3 ms 4952 KB Output is correct
3 Correct 3 ms 4956 KB Output is correct
4 Incorrect 2 ms 4956 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5036 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Incorrect 2 ms 4956 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5036 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Incorrect 2 ms 4956 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Correct 2 ms 5204 KB Output is correct
3 Incorrect 2 ms 4952 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Correct 3 ms 4956 KB Output is correct
3 Incorrect 2 ms 4956 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 3 ms 4952 KB Output is correct
3 Correct 3 ms 4956 KB Output is correct
4 Incorrect 2 ms 4956 KB Output isn't correct
5 Halted 0 ms 0 KB -