QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#68598#4912. WereYouLastZesty_Fox100 ✓4114ms4748kbC++141.8kb2022-12-17 17:29:392022-12-17 17:29:41

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-17 17:29:41]
  • 评测
  • 测评结果:100
  • 用时:4114ms
  • 内存:4748kb
  • [2022-12-17 17:29:39]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using i64=long long;
using u64=unsigned long long;
using db=double;
using pii=pair<int,int>;
using vi=vector<int>;

#define fi first
#define se second
#define pb push_back

void modify(int,bool);
bool query(int);

bool WereYouLast(int n,int m){
    if(n==(1<<10)){
        int pos=1;
        while(pos<=m&&query(pos)) modify(pos++,0);
        if(pos>m) return 1;
        modify(pos,1);return 0;
    }
    else if(n==(1<<16)||n==(1<<20)||n==(1<<26)){
        static const int s1[][2]={{},{2,13},{3,8},{4,6},{5,0},{0,0},{0,7},{0,0},{9,11},{0,10},{0,0},{12,0},{0,0},{14,19},{15,17},{0,16},{0,0},{18,0},{0,0},{20,22},{21,0},{0,0},{0,23},{0,0}};
        static const int s2[][2]={{},{2,17},{3,10},{4,8},{5,0},{6,7},{0,0},{0,0},{0,9},{0,0},{11,0},{12,14},{0,13},{0,0},{15,16},{0,0},{0,0},{18,25},{19,0},{20,22},{0,21},{0,0},{23,24},{0,0},{0,0},{26,30},{27,0},{28,29},{0,0},{0,0},{0,31},{0,0}};
        static const int s3[][2]={{},{2,23},{3,13},{4,8},{5,7},{6,0},{0,0},{0,0},{9,12},{10,11},{0,0},{0,0},{0,0},{14,21},{15,18},{16,17},{0,0},{0,0},{19,20},{0,0},{0,0},{22,0},{0,0},{24,33},{25,29},{26,28},{27,0},{0,0},{0,0},{30,0},{31,32},{0,0},{0,0},{34,38},{35,0},{36,37},{0,0},{0,0},{39,41},{40,0},{0,0},{0,0}};
        
        auto dfs = [&](auto &&self,const int s[][2],int nw) -> bool{
            if(!nw) return 1;
            if(!query(nw)){
                if(self(self,s,s[nw][0])) modify(nw,1);
                return 0;
            }
            else{
                modify(nw,0);
                return self(self,s,s[nw][1]);
            }
        };

        if(n==(1<<16)) return dfs(dfs,s1,1);
        else if(n==(1<<20)) return dfs(dfs,s2,1);
        else return dfs(dfs,s3,1);
    }
    else assert(0);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 2ms
memory: 3556kb

input:

1024 10

output:

12345876 10 10

result:

ok Correct Answer.
C1 = 10.
C2 = 10.

Subtask #2:

score: 20
Accepted

Test #2:

score: 20
Accepted
time: 2ms
memory: 4664kb

input:

65536 100000

output:

12345876 5 5

result:

ok Correct Answer.
C1 = 5.
C2 = 5.

Subtask #3:

score: 30
Accepted

Test #3:

score: 30
Accepted
time: 66ms
memory: 4748kb

input:

1048576 100000

output:

12345876 6 6

result:

ok Correct Answer.
C1 = 6.
C2 = 6.

Subtask #4:

score: 40
Accepted

Test #4:

score: 40
Accepted
time: 4114ms
memory: 4704kb

input:

67108864 100000

output:

12345876 6 6

result:

ok Correct Answer.
C1 = 6.
C2 = 6.