hackerrank Organizing Containers of Balls

来源:互联网 发布:菜鸟网络工资 编辑:程序博客网 时间:2024/05/11 22:08

这里写图片描述

这里写图片描述

#include<stdio.h>#include<iostream>#include<string.h>#include<math.h>#include<algorithm>#include<queue>#include<set>#include<iterator>#include<map>using namespace std;long long container[110];long long type[110];map<int, int> used;int main(){    int t;    scanf("%d", &t);    while(t--){        int M;        memset(type, 0, sizeof(type));        memset(container, 0, sizeof(container));        int n;        scanf("%d", &n);        for(int i = 0; i < n; i++){            for(int j = 0; j < n; j++){                scanf("%d", &M);                type[j] += M;                container[i] += M;             }            used[container[i]] = 1;         }        int flag = 1;        for(int i = 0; i < n; i++){            if(used[type[i]] != 1){                flag = 0;                break;            }        }        if(flag == 1) printf("Possible\n");        else printf("Impossible\n");    }    return 0;}