Submission #171639

# Submission time Handle Problem Language Result Execution time Memory
171639 2019-12-29T12:53:26 Z ToniB Baza (COCI17_baza) C++14
50 / 50
737 ms 7944 KB
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    
    int r[n][m] = {0};
    
    for(int i = 0; i < n; ++i){
    	for(int j = 0; j < m; ++j){
    		cin >> r[i][j];
		}
	}
	
	int q;
	cin >> q;
	
	int sol[q] = {0};
	
	for(int i = 0; i < q; ++i){
		///////////////////////
		
		int all[m] = {0};
		for(int j = 0; j < m; ++j){
			cin >> all[j];
		}
		
		int sv[n] = {0};
		int log = 0;
		
		for(int j = 0; j < m; ++j){
			if(all[j] < 0){
				log += 1;
				continue;
			}
			else{
				for(int k = 0; k < n; ++k){
					if(r[k][j] == all[j]) sv[k] += 1;
				}
			}
		}
		
		for(int j = 0; j < n; ++j){
			sv[j] += log;
		}
		
		for(int j = 0; j < n; ++j){
			if(sv[j] == m) sol[i]++;
		}
	}
	
	for(int i = 0; i < q; ++i){
		cout << sol[i] << endl;
	}
	

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 131 ms 2680 KB Output is correct
2 Correct 87 ms 1832 KB Output is correct
3 Correct 284 ms 5256 KB Output is correct
4 Correct 69 ms 1656 KB Output is correct
5 Correct 208 ms 4060 KB Output is correct
6 Correct 318 ms 6008 KB Output is correct
7 Correct 438 ms 7944 KB Output is correct
8 Correct 263 ms 5112 KB Output is correct
9 Correct 165 ms 3320 KB Output is correct
10 Correct 737 ms 7804 KB Output is correct