http://acm.hdu.edu.cn/showproblem.php?pid=6396
题意:
一个人有k个属性,有n个怪物每个也有k个属性和k个强化,如果各项属性都大于怪物的话,那么就可以杀死怪物,并且强化自己各自的属性
思路:
其实这道题不是太难,只是普通的读入挂不能用就很骚,必须得用fread加强的读入挂。
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <string.h>
#include <queue>
#include <stack>
#include <deque>
#include <stdlib.h>
#include <bitset>
#include <functional>
using namespace std;
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define maxn 100005
#define eps 0.00000001
#define PI acos(-1.0)
#define M 1e9 + 7
//---____________---------__---__--_--_-_-_--_-_-_-__-_-_-___--_-_-_-
namespace fastIO {
#define BUF_SIZE 100000
//fread -> read
bool IOerror = 0;
inline char nc() {
static char buf[BUF_SIZE], *p1 = buf + BUF_SIZE, *pend = buf + BUF_SIZE;
if(p1 == pend) {
p1 = buf;
pend = buf + fread(buf, 1, BUF_SIZE, stdin);
if(pend == p1) {
IOerror = 1;
return -1;
}
}
return *p1++;
}
inline bool blank(char ch) {
return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
}
inline void read(int &x) {
char ch;
while(blank(ch = nc()));
if(IOerror) return;
for(x = ch - '0'; (ch = nc()) >= '0' && ch <= '9'; x = x * 10 + ch - '0');
}
#undef BUF_SIZE
};
using namespace fastIO;
//--________________-___________________________________//
struct XK {
int val, id;
XK(){}
XK(int _val, int _id){
val = _val; id = _id;
}
bool operator > (const XK &a) const {
return val > a.val;
}
bool operator < (const XK &a) const {
return val < a.val;
}
};
struct SX {
int w[10], v[10];
};
priority_queue<XK, vector<XK>, greater<XK> > que[6];
int NanZ[10], hurt[maxn];
SX G[maxn];
int main(int argc, const char * argv[]) {
//freopen("/Volumes/mac 盘/Code/in.txt", "r", stdin);
int T;
read(T);
while(T--) {
int n, k;
read(n); read(k);
memset(hurt, 0, sizeof(hurt));
memset(G, 0, sizeof(G));
for (int i = 0; i < k; i ++)
read(NanZ[i]);
for (int i = 0; i < n; i ++) {
for (int j = 0; j < k; j ++) {
read(G[i].w[j]);
que[j].push(XK(G[i].w[j], i));
}
for (int j = 0; j < k; j ++)
read(G[i].v[j]);
}
int ans = 0;
bool Flag = 1;
while(Flag) {
Flag = 0;
for (int i = 0; i < k; i ++) {
while(!que[i].empty()) {
XK t = que[i].top();
if(t.val <= NanZ[i]) {
hurt[t.id] ++;
que[i].pop();
if(hurt[t.id] == k) {
for (int i = 0; i < k; i ++)
NanZ[i] += G[t.id].v[i];
ans ++;
Flag = 1;
}
}else
break;
}
}
}
printf("%d\n", ans);
for (int i = 0; i < k; i ++)
printf("%d%c", NanZ[i], i == k - 1? '\n' : ' ');
for (int i = 0; i < 6; i ++)
while(!que[i].empty())
que[i].pop();
}
return 0;
}