QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#341016#993. 100 Boxes Per Hour...ucup-team1209#AC ✓6ms3584kbC++203.2kb2024-02-29 15:02:052024-02-29 15:02:07

Judging History

你现在查看的是测评时间为 2024-02-29 15:02:07 的历史记录

  • [2024-02-29 16:30:14]
  • 管理员手动重测该提交记录
  • 测评结果:AC
  • 用时:31ms
  • 内存:3824kb
  • [2024-02-29 15:02:07]
  • 评测
  • 测评结果:0
  • 用时:6ms
  • 内存:3584kb
  • [2024-02-29 15:02:05]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define drep(i,y,x) for (int i=(y);i>=(x);i--)
#define pii pair<int,int>
#define fir first
#define sec second
#define MP make_pair
template<typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template<typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}
void file() {
    #ifdef zqj
    freopen("a.in","r",stdin);
    #endif
}

int cnt[3];

int ccc[2];
char sss[2];
char cur; 

void init(){
    rep(i,0,2) cin>>cnt[i];
    ccc[0]= ccc[1] =sss[0]=sss[1]=0;
}
void place(int p) {
    assert(sss[p] == 0 || sss[p] == cur);
    cout<<"PLACE "<<p+1<<'\n'<<endl;
    sss[p] = cur; 
    ++ ccc[p];
    fflush(stdout);
}
void drop() {
    cout<<"DISCARD\n"<<endl;
    fflush(stdout);
}
void empty(int p) {
    cout<<"EMPTY "<<p+1<<'\n';
    sss[p] = ccc[p] = 0; 
    fflush(stdout);
}
char getinput() {
    char ch; cin>>ch; if(ch == '-') assert(0); cur = ch; return ch;
}

void work() {
    const int T=100;
    init();
    empty(0);
    empty(1);
    sort(cnt,cnt+3);
    if (cnt[0]+cnt[1]>=43) {
        char s[2]={0,0};
        rep(i,1,T) {
            char ch=getinput();
            if (ch==s[0]) place(0);
            else if (ch==s[1]) place(1);
            else if (s[0]==0) place(0),s[0]=ch;
            else if (s[1]==0) place(1),s[1]=ch;
            else drop();
        }
        assert(ccc[0] + ccc[1] >= 43);
        return;
    }
    if (cnt[0]<=17) {
        char s[2]={0,0};
        int cc[2] = {0, 0};
        map<char,int>dropped;
        rep(i,1,T) {
            char ch=getinput();
            if (dropped[ch]<cnt[0]) drop(),dropped[ch]++;
            else if (ch==s[0]) place(0), ++ cc[0];
            else if (ch==s[1]) place(1), ++ cc[1];
            else if (s[0]==0) place(0),s[0]=ch, ++ cc[0];
            else if (s[1]==0) place(1),s[1]=ch, ++ cc[1];
            else assert(0);
        }
        assert(cc[0] + cc[1] >= T - 3 * cnt[0]);
        assert(cc[0] + cc[1] >= 43);
        assert(ccc[0] + ccc[1] >= 43);
        return;
    }
    char s[2]={0,0};
    int cc[2]={0,0};
    map<char,int>dropped;
    int flg=-1;
    rep(i,1,T) {
        char ch=getinput();
        if (ch==s[0]) place(0),++cc[0];
        else if (ch==s[1]) place(1),++cc[1];
        else if (s[0]==0) place(0),++cc[0],s[0]=ch;
        else if (s[1]==0) place(1),++cc[1],s[1]=ch;
        else {
            if (flg==-1) {
                if (dropped[ch]<cnt[0]) drop(),dropped[ch]++;
                else if (cc[0]<=cnt[0]) empty(0),place(0),dropped[s[0]]=cc[0],cc[0]=1,flg=0,s[0]=ch;
                else if (cc[1]<=cnt[0]) empty(1),place(1),dropped[s[1]]=cc[1],cc[1]=1,flg=1,s[1]=ch;
                else assert(0);
            }
            else if (flg==-2) drop();
            else {
                if (dropped[ch]<cnt[1]) drop(),dropped[ch]++;
                else empty(flg),place(flg),cc[flg]=1,s[flg]=ch,flg=-2;
            }
        }
    }
    assert(cc[0] + cc[1] >= T - 2 * cnt[1]);
    assert(cc[0] + cc[1] >= 43);
    assert(ccc[0] + ccc[1] >= 43);
}

int main() {
    int _; cin>>_;
    while (_--) work();
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 6ms
memory: 3584kb

input:

100
3 33 64
B
G
R
R
G
R
B
R
G
R
R
B
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
R
R
G
84 8 8
B
B
B
R
R
R
R
R
G
G
G
G
G
G
G
G
B
B
B
B
B
B
B
B
B
B
B
B
R
B
B
B
B
B
B
B
B
B
B
B
B...

output:

EMPTY 1
EMPTY 2
DISCARD

DISCARD

DISCARD

DISCARD

DISCARD

DISCARD

DISCARD

PLACE 1

DISCARD

PLACE 1

PLACE 1

DISCARD

PLACE 2

PLACE 1

PLACE 1

PLACE 2

PLACE 1

PLACE 1

PLACE 2

PLACE 1

PLACE 1

PLACE 2

PLACE 1

PLACE 1

PLACE 2

PLACE 1

PLACE 1

PLACE 2

PLACE 1

PLACE 1

PLACE 2

PLACE...

result:

wrong answer ok  OK