QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#589375 | #5140. Frozen Scoreboard | gates_orz | WA | 4ms | 3720kb | C++14 | 5.9kb | 2024-09-25 17:33:57 | 2024-09-25 17:33:59 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fi first
#define se second
#define lowbit(x) (x&(-x))
//typedef long long ll;
//typedef unsigned long long ull;
const int N = 3e5 + 10, M = 1e5,mod=998244353;
int n, m;
typedef pair<int,int>PII;
struct Node {
char sta;
int x,y;
};
struct node {
int x,y,id;
bool operator<(const node &b) const {
return x<b.x;
}
};
bool cmp(const node &a,const node &b) {
return a.x<b.x;
}
void solve(){
cin>>n>>m;
for(int i=1;i<=n;i++) {
int ac,pe;
cin>>ac>>pe;
int now_ac=0,now_pe=0;
vector<Node>v(m+1);
vector<node>have;
for(int j=1;j<=m;j++) {
char c;
cin>>c;
if(c=='.') {
v[j]={c};
}
else if(c=='+') {
now_ac++;
int x,y;
scanf("%d/%d",&x,&y);
now_pe+=y+(x-1)*20;
v[j]={c,x,y};
}
else if(c=='?') {
int x,y;
cin>>x>>y;
v[j]={c,x,y};
have.push_back({y-x,y,j});
}
else if(c=='-') {
int x;
cin>>x;
v[j]={c,x};
}
}
sort(have.begin(), have.end(), [&](node a,node b) {
return a.y>b.y;
});
int sum = pe - now_pe;
int k = ac - now_ac;
if (sum < 0 || k < 0 || have.size() < k) {
cout << "No" << "\n";
continue;
}
int t = sum - k * 240;
vector<int>pn;
int sum_x=0,sum_y=0;
/*for(int j=0;j<have.size();j++) {
if(now_ac<ac&&t>=20*(have[j].y-1)) {
t-=20*(have[j].y-1);
v[have[j].id].x=have[j].y;
v[have[j].id].sta='+';
now_ac++;
pn.push_back(have[j].id);
//cerr<<"?\n";
//cerr<<"id="<<have[j].id<<"\n";
}
else if(now_ac<ac&&t>=20*(have[j].x)){
//cerr<<"x="<<t/20+1<<"\n";
v[have[j].id].x=t/20+1;
v[have[j].id].sta='+';
t%=20;
now_ac++;
pn.push_back(have[j].id);
//cerr<<"???\n";
}
}*/
priority_queue<PII>heap;
set<node>st;
set<int>chose;
for(int j=0;j<k;j++) {
sum_y+=have[j].y-1;
sum_x+=have[j].x;
heap.push({have[j].x,have[j].id});
chose.insert(have[j].id);
}
if(sum_y*20+59*k<t) {
cout<<"No"<<"\n";
continue;
}
for(int j=k;j<have.size();j++) {
st.insert(have[j]);
}
while(sum_x*20>t) {
sum_x-=heap.top().first;
sum_y-=v[heap.top().second].y-1;
chose.erase(heap.top().second);
heap.pop();
node del={};
int sign=0;
for(auto tmp:st) {
if((tmp.y-1+sum_y)*20+59*k>=t) {
sum_y+=tmp.y-1;
chose.insert(tmp.id);
del=tmp;
sign=1;
break;
}
}
if(sign) {
st.erase(del);
}
}
if(sum_x*20<=t&&sum_y*20+58*k>=t);
else {
cout<<"No"<<"\n";
continue;
}
for(auto tmp:chose) {
pn.push_back(tmp);
}
for(int j=0;j<pn.size();j++) {
int id=pn[j];
v[id].sta='+';
t-=(v[id].y-v[id].x)*20;
}//||now_ac!=ac
//cerr<<"t="<<t<<"\n";
for(int j=0;j<pn.size();j++) {
int id=pn[j];
//cerr<<"id="<<id<<"\n";
int x=v[id].x,y=v[id].y-1;
//cerr<<"x="<<x<<" y="<<y<<"\n";
if((x-1)*20<=t) {
v[id].x=x-1;
t-=(x-1)*20;
if(t>=59) {
v[id].y=299;
t-=59;
}
else {
v[id].y=240+t;
t=0;
}
}
else {
//cerr<<"t="<<t<<"\n";
v[id].x=(v[id].y-v[id].x)+t/20+1;
t%=20;
if(t>=59) {
v[id].y=299;
t-=59;
}
else {
v[id].y=240+t;
t=0;
}
}
}
if(t) {
//cerr<<"t="<<t<<"\n";
cout<<"No"<<"\n";
continue;
}
now_ac=0;
now_pe=0;
for(int j=1;j<=m;j++) {
if(v[j].sta=='+') {
now_ac++;
now_pe+=(v[j].x-1)*20+v[j].y;
}
}
if(now_ac!=ac||now_pe!=pe) {
cout<<"No"<<"\n";
continue;
}
cout<<"Yes"<<"\n";
for(int j=1;j<=m;j++) {
auto [sta,x,y]=v[j];
if(sta=='.') {
cout<<"."<<"\n";
}
else if(sta=='+') {
cout<<sta<<" "<<x<<"/"<<y<<"\n";
}
else if(sta=='?') {
cout<<"- "<<y<<"\n";
}
else if(sta=='-') {
cout<<"- "<<x<<"\n";
}
}
}
}
/*
1 13
7 951
+ 1/6
? 3 4
+ 4/183
- 2
+ 3/217
.
.
.
+ 2/29
+ 1/91
.
+ 1/22
.
*/
/*
6 2
1 100
.
? 3 4
2 100
+ 1/1
+ 1/2
0 0
- 5
- 6
2 480
? 100 100
? 100 100
2 480
? 99 100
? 100 100
1 2000
? 100 100
? 100 100
*/
signed main() {
/*ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);*/
int T;
T = 1;
//cin>>T;
while (T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
input:
1 13 7 951 + 1/6 ? 3 4 + 4/183 - 2 + 3/217 . . . + 2/29 + 1/91 . + 1/22 .
output:
Yes + 1/6 + 3/243 + 4/183 - 2 + 3/217 . . . + 2/29 + 1/91 . + 1/22 .
result:
ok ok (1 test case)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
6 2 1 100 . ? 3 4 2 100 + 1/1 + 1/2 0 0 - 5 - 6 2 480 ? 100 100 ? 100 100 2 480 ? 99 100 ? 100 100 1 2000 ? 100 100 ? 100 100
output:
No No Yes - 5 - 6 Yes + 1/240 + 1/240 No Yes + 89/240 - 100
result:
ok ok (6 test cases)
Test #3:
score: -100
Wrong Answer
time: 4ms
memory: 3628kb
input:
1000 13 6 1519 + 3/183 - 1 + 9/133 ? 2 3 - 5 ? 1 3 - 5 ? 1 1 ? 1 3 - 5 + 1/165 - 6 ? 2 5 2 570 - 2 - 9 . - 1 - 7 - 6 + 4/179 - 2 ? 2 5 . - 2 ? 1 3 . 1 140 . - 2 . - 2 - 1 - 2 - 2 . . . . + 3/100 . 1 195 + 1/195 . . . . . . . . ? 1 1 . . . 0 0 . . . . . . . . . . . . . 3 776 ? 8 22 ? 1 8 - 6 + 1/173 ...
output:
No No Yes . - 2 . - 2 - 1 - 2 - 2 . . . . + 3/100 . Yes + 1/195 . . . . . . . . - 1 . . . Yes . . . . . . . . . . . . . No No No Yes - 23 . - 3 - 6 - 10 - 2 - 8 - 10 - 12 - 7 - 7 - 8 - 8 No Yes . - 1 - 5 . . - 2 . - 6 . - 5 . - 2 - 6 Yes + 16/237 - 3 - 3 - 2 - 10 - 9 - 12 - 2 - 6 . + 2/185 - 4 - 7 N...
result:
wrong answer ans finds the answer, but out doesn't (test case 1)