QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#426872#8724. Septembernvujica0 0ms0kbC++141.1kb2024-05-31 23:39:442024-05-31 23:39:46

Judging History

你现在查看的是最新测评结果

  • [2024-05-31 23:39:46]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-05-31 23:39:44]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long
#define fi first
#define se second

using namespace std;

const int maxn = 1e5 + 10;

int par[maxn];
int poz[maxn];
vector <int> v[maxn];

//int rek(int x, int mini){
//	for(int i = 0; i < v[x].size(); i++){
//		int x2 = v[x][i];
//		
//		if(mini < poz[x2]){
//			auto it = --s.lower_bound({mini + 1, 0});
//			int l = (*it).fi;
//			auto it2 = --s.lower_bound({mini + 1});
//			int r = (*it).se
//		}
//	}
//}

int solve(int n, int m, vector <int> f, vector <vector<int> > s){
	for(int i = 0; i < n; i++){
		v[i].clear();
	}
	
	for(int i = 0; i < n; i++){
		par[i] = f[i];
		v[par[i]].push_back(i);
	}
	
//	cout << s[0][0] << endl;
	
	for(int i = 0; i < n - 1; i++){
		poz[s[0][i]] = i;
	}
	
//	cout << "tu sam" << endl;
	
	int ans = 0;
	
	int cnt = 0;
	
	for(int i = 0; i < n - 1; i++){
		int x = s[0][i];
		
//		cout << x << endl;
		
		for(int j = 0; j < v[x].size(); j++){
			int x2 = v[x][j];
			
			if(i < poz[x2]) cnt++;
		}
		
		if(par[x] && poz[par[x]] < i) cnt--;
		
//		cout << i << ' ' << cnt << endl;
		
		if(cnt == 0) ans++;
	}
	
	return ans;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
4
7 1
0 0 2 3 3 5
1 6 4 3 5 2
10 1
0 1 2 0 3 0 5 4 8
9 7 6 8 4 5 3 2 1
7 1
0 0 0 1 3 0
2 4 1 6 5 3
6 1
0 0 1 1 3
4 5 2 3 1

output:


result:


Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Runtime Error

Test #17:

score: 0
Runtime Error

input:

txy4h26c1rm1uv8tr3eonahd67u8h56x
53
10 1
0 1 2 3 4 5 6 7 8
9 8 7 6 5 4 3 2 1
10 1
0 1 2 3 4 5 6 7 8
9 7 8 5 6 4 3 2 1
10 1
0 1 2 3 4 5 6 7 8
8 9 7 5 6 3 2 4 1
10 1
0 1 2 3 4 5 6 7 8
8 9 6 7 5 4 3 2 1
10 1
0 1 2 3 4 5 6 7 8
8 9 7 5 6 3 4 2 1
10 1
0 1 2 3 4 5 6 7 8
9 8 7 6 5 4 2 3 1
10 1
0 1 2 3 4 5 6...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #3:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%

Subtask #7:

score: 0
Skipped

Dependency #3:

0%

Subtask #8:

score: 0
Skipped

Dependency #1:

0%

Subtask #9:

score: 0
Skipped

Dependency #3:

0%

Subtask #10:

score: 0
Skipped

Dependency #1:

0%