20200725 PAT甲级 7-2 The Judger (25分)

#include 
#include 
#include 
using namespace std;

int exist[100010]={0}, diff[100010] = {0}; 
// exist记录已经报过的数,diff记录已经报过的数的差值
vector<int> exists;
// exists记录已经报过的数,对于每个新报的数,和每个已存的数相减得差
int ht[15] = {0};
int a[1010][1010];


int main() {
		
    int n1, n2;
    scanf("%d%d", &n1, &n2);

    diff[abs(n1 - n2)] = 1;
    exist[n1] = 1;
    exist[n2] = 1;
    exists.push_back(n1);
    exists.push_back(n2);
    
    int n, m;
    scanf("%d%d", &n, &m);
    
    for(int i = 1; i <= n; i++) 
    	for(int j = 1; j <= m; j++) 
    		scanf("%d", &a[i][j]); 
    		
	for(int j = 1; j <= m; j++) {
		for(int i = 1; i <= n; i++) {
			
			if(ht[i] == 1) continue;

    		int t = a[i][j];

    		if(diff[t] && !exist[t]) {
    			
    			for(int i = 0; i < exists.size(); i++) {
    				int t2 = exists[i];
    				diff[abs(t - t2)] = 1;
    			}
    			exist[t] = 1;
    			exists.push_back(t);
    		} else {
    			ht[i] = 1;
    			printf("Round #%d: %d is out.\n", j, i);
    		}
		}
	}

    int f = 1;
    for(int i = 1; i <= n; i++) {
    	if(ht[i] == 0) {
    		if(f) printf("Winner(s):");
    		printf(" %d", i);
    		f = 0;
    	}
    }
    if(f) printf("No winner.");

    return 0;
}

sad 考完补的 其实就是理顺了考试时候的思路 当时看到通过率才0.02还0.03就慌了觉得自己肯定不行orz(题目看懂却没写出来的估计就我一个白痴了……
测试样例过了,不知实际oj如何……

你可能感兴趣的:(PAT甲级)