QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#792017 | #686. Bad Doctor | Ame_Rain_chan | RE | 0ms | 0kb | C++14 | 2.2kb | 2024-11-28 22:53:46 | 2024-11-28 22:53:47 |
answer
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=5e5+10;
int n,m,c[N];
struct pt{
int l,r;
}p[N];
vector<int> x[N];
unordered_set<int> st[N];
int main(){
freopen("doctor.in","r",stdin);
freopen("doctor.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i=1;i <= m;i++) scanf("%d",&c[i]);
int mi=1e9,ma=-1e9;
for(int i=1;i <= n;i++){
int t;scanf("%d%d%d",&p[i].l,&p[i].r,&t);
mi=min(mi,p[i].l),ma=max(ma,p[i].r);
for(int j=1;j <= t;j++){
int q;scanf("%d",&q);
x[i].push_back(q);
}
}
if(n <= 310 && m <= 310){
for(int i=1;i <= n;i++){
ll res=0;
for(int j=mi;j <= ma;j++) st[j].clear();
//cerr << "delete: " << i << "\n";
for(int j=1;j <= n;j++){
if(j == i) continue;
//cerr << "message: " << p[j].l << " " << p[j].r << "\n";
for(int k=p[j].l;k <= p[j].r;k++){
for(auto t:x[j]){
if(st[k].count(t)) continue;
st[k].insert(t);
res += c[t];
//cerr << k << " " << t << "\n";
}
}
}
printf("%lld ",res);
}
} else {
for(int i=1;i <= n;i++){
ll res=0;int mi=1e9,ma=-1e9;
for(int j=1;j <= n;j++){
if(j == i) continue;
for(int k=p[j].l;k <= p[j].r;k++){
for(auto t:x[j]){
if(st[k].count(t)) continue;
st[k].insert(t);
res += c[t];
//cerr << k << " " << t << "\n";
}
}
printf("%lld ",res);
}
/*
for(int j=mi;j <= ma;j++){
res += 0;
}
*/
}
}
return 0;
}
/*
g++ doctor.cpp -o doctor -std=c++14 -O2 -static -Wall -Wextra -fsanitize=undefined
./doctor < doctor.in > doctor.out
*/
詳細信息
Test #1:
score: 0
Dangerous Syscalls
input:
5 4 1000 100 10 1 3 4 2 2 3 4 8 3 1 2 4 6 7 2 3 4 8 9 2 1 4 2 6 3 1 2 3