QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#589541 | #5140. Frozen Scoreboard | gates_orz | WA | 2ms | 3932kb | C++14 | 5.2kb | 2024-09-25 18:22:49 | 2024-09-25 18:22:49 |
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};
}
}
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>vis(have.size(),0);
vector<int>vvis(have.size(),0);
auto check = [&]() {
int sum_x=0,sum_y=0;
//cerr<<"vis: ";
for(int j=0;j<have.size();j++) {
//cerr<<vvis[j]<<" ";
if(vvis[j]) {
int id=have[j].id;
sum_x+=v[id].y-v[id].x;
sum_y+=v[id].x-1;
}
}
//cerr<<"\n";
if(sum_x*20<=t&&sum_y*20+59*k>=t)return true;
return false;
};
int sign=0;
//cerr<<"k="<<k<<"\n";
auto dfs=[&](auto &self,int p,int need)->void {
if(sign)return;
if(p>=have.size()) {
if(need==0) {
//cerr<<"need="<<need<<"\n";
if(check()) {
sign=1;
vis=vvis;
}
}
return;
}
if(need) {
vvis[p]=1;
self(self,p+1,need-1);
vvis[p]=0;
}
self(self,p+1,need);
};
dfs(dfs,0,k);
if(!sign) {
cout<<"No"<<"\n";
continue;
}
//cerr<<"vis: ";
//for(int j=0;j<have.size();j++)cerr<<vis[j]<<" ";cerr<<"\n";
for(int j=0;j<have.size();j++) {
if(vis[j]) {
int id=have[j].id;
t-=(v[id].y-v[id].x)*20;
}
}
if(t<0) {
cout<<"No"<<"\n";
continue;
}
for(int j=0;j<have.size();j++) {
if(vis[j]) {
int id = have[j].id;
//cerr<<"id="<<id<<"\n";
if (t >= (v[id].x - 1) * 20) {
t -= (v[id].x - 1) * 20;
v[id].sta = '+';
v[id].x = v[id].y;
if (t >= 59) {
v[id].y = 299;
t -= 59;
} else {
v[id].y = 240 + t;
t = 0;
}
} else {
//cerr<<"???"<<"\n";
v[id].sta = '+';
v[id].x = (v[id].y - v[id].x) + (t / 20) + 1;
t %= 20;
v[id].y = 240 + t;
t = 0;
}
}
}
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) {
//cerr<<"now_ac="<<now_ac<<" now_pe="<<now_pe<<"\n";
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: 3716kb
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: 3696kb
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: 2ms
memory: 3932kb
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:
Yes + 3/183 - 1 + 9/133 + 3/278 - 5 + 3/240 - 5 + 1/240 - 3 - 5 + 1/165 - 6 - 5 No Yes . - 2 . - 2 - 1 - 2 - 2 . . . . + 3/100 . Yes + 1/195 . . . . . . . . - 1 . . . Yes . . . . . . . . . . . . . No Yes . - 1 + 1/285 - 1 + 1/60 . . - 1 . . . . . Yes . - 1 . + 6/257 - 7 - 2 + 1/240 - 9 + 3/213 - 7 +...
result:
wrong answer ans finds the answer, but out doesn't (test case 2)