当前位置:网站首页>P5594 [xr-4] simulation match

P5594 [xr-4] simulation match

2022-07-07 23:40:00 Yuesi

P5594 【XR-4】 Simulation game

subject
X The school is in progress CSP Before the school training .
Altogether n name OIer Participate in this training , The coach carefully prepared for them m Set of simulation questions .
However , Each OIer Each has its own schedule , Coincidentally, , They are in the next k There happens to be m I'm free to play a mock race .
For the convenience of management , The coach stipulated that one must finish the game in order m Set of simulation questions .
such as , Small X In the next 2,3,5 I'm free to play a mock race , Then he must be in the 2 Tiandadi 1 Set of simulation questions , The first 3 Tiandadi 2 Set of simulation questions , The first 5 Tiandadi 3 Set of simulation questions .

The coach needs to prepare everyone for every practice match , In order to reduce the workload , If there are many people playing the same set of simulation questions on a certain day , Then the coach only needs to prepare a simulation match using this set of questions on this day .
As a computer room boss , The coach wants you to help him calculate , How many practice matches does he need to prepare every day

Input format
The first row has three integers n,m,k.
Next n That's ok , Each row m It's an integer , The first i Xing di j Integer of column ai,j
It means the first one i Personal in the next k The second day of the day j The first free day is ai,j God .

Output format
a line k It's an integer , The first i An integer represents the next i The number of simulated games the coach needs to prepare .

I/o sample
Input #1
1 3 5
2 3 5
Output #1
0 1 1 0 1
Input #2
6 3 7
2 3 4
2 5 7
3 5 7
1 3 5
5 6 7
1 2 3
Output #2
1 2 3 1 3 1 1
Input #3
10 10 20
2 3 4 8 9 11 12 16 17 18
2 3 6 10 12 13 14 15 19 20
1 3 7 10 11 13 14 15 17 19
1 2 4 6 7 9 15 17 19 20
2 3 5 6 9 11 14 16 19 20
1 2 3 8 9 10 11 12 15 19
1 4 6 7 9 12 13 17 18 19
1 7 8 9 10 11 13 15 18 20
1 5 6 7 8 9 13 16 18 19
4 5 7 10 11 13 14 17 18 20
Output #3
1 2 2 3 2 2 4 3 3 3 3 4 2 1 3 1 2 2 2 1

explain / Tips
This question adopts the bundling test .
Subtask 1(13 points):n = m = k = 1.
Subtask 2(24 points):n = 1.
Subtask 3(24 points):m = 1.
Subtask 4(39 points): No special restrictions .
about 100%100% The data of ,1 ≤ n,m,k<=10^3 ,m≤k,
1 ≤ai,1 <ai,2<⋯<a i,m≤k.

Ideas :
You can use grouping by test paper , The same column of read data indicates different test days for the same test paper ,
Just record the first occurrence of each column of days
For example, data 2 Enter the first column ( The number of days for the first set of examination papers is 1,2,3,5,6) Then this 5 At least one exam will be held every day, with one exam paper
The second column records the date of the second set of papers

#include<bits/stdc++.h>
using namespace std;
int main(){
    
	int ans[1005][1005];
	int ka[1005],num=0;
	int n,m,k;//n personal ,m Empty days , in total k God 
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++){
    
		for(int h=1;h<=m;h++){
    
			scanf("%d",&ans[i][h]);// Save to array , Easy to count  
		}
	} 
	bool b[1005]={
    0};// See if there has been the same exam on the same day  
	int bn[1005]={
    0};// Record 1-k On the same day of each day, the number of different examination papers  
	for(int i=1;i<=m;i++){
    
		num=0;
		for(int h=1;h<=n;h++){
    
			if(b[ans[h][i]]==0){
    
				bn[ans[h][i]]++;
				b[ans[h][i]]=1;
				ka[num]=ans[h][i];// Used for restoring and weight removal b[1000] 
				num++;
			}
		}
/* for(int i=1;i<=k;i++){ printf("%d",bn[i]); if(i<k){ printf(" "); } } printf("\n");*/        // Used to check the results or observe whether each step is correct  
		for(int j=0;j<num;j++){
    
			b[ka[j]]=0;// Restore the de duplicated array  
		}
	}
	for(int i=1;i<=k;i++){
    // Output final results , Note blank space  
		printf("%d",bn[i]);
		if(i<k){
    
			printf(" ");
		}
	}
	return 0;
}
原网站

版权声明
本文为[Yuesi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130556374902.html