QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#610746 | #5140. Frozen Scoreboard | zake | WA | 0ms | 3580kb | C++17 | 2.8kb | 2024-10-04 17:15:30 | 2024-10-04 17:15:30 |
Judging History
answer
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
struct node{
char op;
int x,time,id;
};
struct node1{
int sub,x,id;
int mn,mx;
};
bool cmp(node1 a,node1 b){
if(a.mn==b.mn) return a.mx>b.mx;
return a.mn<b.mn;
}
bool cmp1(node1 a,node1 b){
if(a.mx==b.mx) return a.mn<b.mn;
return a.mx>b.mx;
}
int number_of_1(int m)
{
int count = 0;
while (m)
{
m = m & (m - 1);
count++;
}
return count;
}
const int N=2e5+5;
node a[N];
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
int n,m;
cin>>n>>m;
while(n--){
int flag1=0;
int x,time;
cin>>x>>time;
int nowt=0,nowx=0;
vector<node1> res;
for(int i=1;i<=m;i++){
cin>>a[i].op;
a[i].id=i;
if(a[i].op=='+'){
string s;
cin>>s;
int xx=0,tt=0;
bool flag=0;
for(auto e:s){
if(e=='/'){
flag=1;
continue;
}
if(!flag) xx=xx*10+(int)(e-'0');
else tt=tt*10+(int)(e-'0');
}
a[i].x=xx;
a[i].time=tt;
nowt+=tt+(xx-1)*20;
nowx++;
}
else if(a[i].op=='?'){
node1 tmp;
tmp.id=i;
cin>>tmp.sub>>tmp.x;
tmp.mn=240+(tmp.x-tmp.sub)*20;
tmp.mx=299+(tmp.x-1)*20;
res.pb(tmp);
}
else if(a[i].op=='-'){
cin>>a[i].x;
}
}
int tt=time-nowt;
int cnt1=x-nowx;
int S=res.size();
for(int i=0;i<(1<<S);i++){
if(number_of_1(i)!=cnt1){
continue;
}
for(int j=0;j<S;j++){
if((i>>j)&1){
tt-=(240+(res[j].x-res[j].sub)*20);
}
}
if(tt<0){
continue;
}
for(int j=0;j<S;j++){
if((i>>j)&1){
tt-=min(res[j].sub-1,tt/20)*20;
}
}
if(tt<0){
continue;
}
for(int j=0;j<S;j++){
if((i>>j)&1){
tt-=min(tt,59);
}
}
if(tt<0){
continue;
}
if(tt==0){
tt=time-nowt;
for(int j=0;j<S;j++){
if((i>>j)&1){
a[res[j].id].op='+';
tt-=(240+(res[j].x-res[j].sub)*20);
}else{
a[res[j].id].op='-';
a[res[j].id].x=res[j].x;
}
}
for(int j=0;j<S;j++){
if((i>>j)&1){
int tmp=min(res[j].sub-1,tt/20);
tt-=tmp*20;
a[res[j].id].x=res[j].x-res[j].sub+tmp+1;
a[res[j].id].time+=240;
}
}
for(int j=0;j<S;j++){
if((i>>j)&1){
a[res[j].id].time+=min(tt,59);
tt-=min(tt,59);
}
}
cout<<"Yes\n";
for(int i=1;i<=m;i++){
if(a[i].op=='+'){
cout<<"+ "<<a[i].x<<"/"<<a[i].time<<'\n';
}else if(a[i].op=='-'){
cout<<"- "<<a[i].x<<'\n';
}else{
cout<<"."<<'\n';
}
}
flag1=1;
break;
}
}
if(flag1==0)
cout<<"No\n";
}
return 0;
}
/*
1 13
7 951
+ 1/6
? 3 4
+ 4/183
- 2
+ 3/217
.
.
.
+ 2/29
+ 1/91
.
+ 1/22
.
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3580kb
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: -100
Wrong Answer
time: 0ms
memory: 3552kb
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/241 + 1/242 No Yes + 89/481 - 100
result:
wrong answer wrong total time (test case 4)