QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#306702#7979. 棋盘hos_lyric80 412ms13620kbD2.7kb2024-01-17 02:15:062024-01-17 02:15:08

Judging History

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

  • [2024-01-17 02:15:08]
  • 评测
  • 测评结果:80
  • 用时:412ms
  • 内存:13620kb
  • [2024-01-17 02:15:06]
  • 提交

answer

import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }

string COLOR(string s = "") { return "\x1b[" ~ s ~ "m"; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const L = readInt;
      const Q = readInt;
      const X = readInt;
      const Y = readInt;
      auto K = new BigInt[Q];
      foreach (q; 0 .. Q) {
        K[q] = BigInt(readToken);
      }
      
      const maxK = K.maxElement;
      
      /*
        0 1 2
         +---
        3|0 1 2
          3
      */
      alias Pt = Tuple!(int, "x", int, "y");
      const len = (Y + 4 - 1) / 4 * 4;
      auto ps = new Pt[len * 4];
      auto fs = new BigInt[len * 4];
      foreach (i; 0 .. len) {
        ps[i * 4 + 0] = Pt(i + 0, i + 0);
        ps[i * 4 + 1] = Pt(i + 0, i + 1);
        ps[i * 4 + 2] = Pt(i + 0, i + 2);
        ps[i * 4 + 3] = Pt(i + 1, i + 0);
        if (i == 0) {
          fs[0 .. 4] = BigInt(1);
        } else {
          fs[i * 4 + 0] = fs[(i-1) * 4 + 1] + fs[(i-1) * 4 + 3];
          fs[i * 4 + 1] = fs[(i-1) * 4 + 2] + fs[i * 4 + 0];
          fs[i * 4 + 2] = fs[i * 4 + 1];
          fs[i * 4 + 3] = fs[i * 4 + 0];
        }
      }
      debug {
        writeln("fs = ", fs[0 .. 40]);
      }
      
      writeln(X);
      foreach (j; 0 .. X) {
        writeln(ps[j].x + 1, " ", ps[j].y + 1);
      }
      foreach (q; 0 .. Q) {
        auto ans = new char[X];
        ans[] = '0';
        BigInt k = K[q];
        foreach_reverse (j; 0 .. X) {
          if (k >= fs[j]) {
            k -= fs[j];
            ans[j] = '1';
          }
        }
        writeln(ans);
      }
    }
  } catch (EOFException e) {
  }
}

详细

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 11ms
memory: 5976kb

input:

3 999 1000 340
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
...

output:

1000
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 2
3 3
3 4
3 5
4 3
4 4
4 5
4 6
5 4
5 5
5 6
5 7
6 5
6 6
6 7
6 8
7 6
7 7
7 8
7 9
8 7
8 8
8 9
8 10
9 8
9 9
9 10
9 11
10 9
10 10
10 11
10 12
11 10
11 11
11 12
11 13
12 11
12 12
12 13
12 14
13 12
13 13
13 14
13 15
14 13
14 14
14 15
14 16
15 14
15 15
15 16
15 17
16 15
16 ...

result:

ok correct

Subtask #2:

score: 10
Accepted

Test #2:

score: 10
Accepted
time: 103ms
memory: 6176kb

input:

12 10000 1000 340
358908473750
36343501002
904324605639
453955046266
725478753662
218319365131
882878650993
648345848966
474401697383
722377018680
718743783955
748051292505
167886140898
411111004914
327825244967
990026144963
623309580364
970889332700
319445927842
527624602835
453135227321
1153226125...

output:

1000
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 2
3 3
3 4
3 5
4 3
4 4
4 5
4 6
5 4
5 5
5 6
5 7
6 5
6 6
6 7
6 8
7 6
7 7
7 8
7 9
8 7
8 8
8 9
8 10
9 8
9 9
9 10
9 11
10 9
10 10
10 11
10 12
11 10
11 11
11 12
11 13
12 11
12 12
12 13
12 14
13 12
13 13
13 14
13 15
14 13
14 14
14 15
14 16
15 14
15 15
15 16
15 17
16 15
16 ...

result:

ok correct

Test #3:

score: 0
Accepted
time: 110ms
memory: 4400kb

input:

12 10000 1000 340
930556110177
377904923573
36236934395
488122716493
51121341209
392176146788
323693311937
449196823461
336471392319
92713238333
281418059653
761936598942
293730650349
106748001462
609643804851
703543108800
999258707162
376689099489
435462123411
710775118008
45582546742
835557591196
...

output:

1000
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 2
3 3
3 4
3 5
4 3
4 4
4 5
4 6
5 4
5 5
5 6
5 7
6 5
6 6
6 7
6 8
7 6
7 7
7 8
7 9
8 7
8 8
8 9
8 10
9 8
9 9
9 10
9 11
10 9
10 10
10 11
10 12
11 10
11 11
11 12
11 13
12 11
12 12
12 13
12 14
13 12
13 13
13 14
13 15
14 13
14 14
14 15
14 16
15 14
15 15
15 16
15 17
16 15
16 ...

result:

ok correct

Test #4:

score: 0
Accepted
time: 103ms
memory: 4208kb

input:

12 10000 1000 340
737930395319
182266797635
731674395027
268811900200
40636281734
385606961047
579973266668
244481758021
889308913416
116731076438
760018797175
690646649762
295657481984
860132997501
798927396859
973501342055
371555705903
89078273643
755892420101
664745115837
527923357928
12789900388...

output:

1000
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 2
3 3
3 4
3 5
4 3
4 4
4 5
4 6
5 4
5 5
5 6
5 7
6 5
6 6
6 7
6 8
7 6
7 7
7 8
7 9
8 7
8 8
8 9
8 10
9 8
9 9
9 10
9 11
10 9
10 10
10 11
10 12
11 10
11 11
11 12
11 13
12 11
12 12
12 13
12 14
13 12
13 13
13 14
13 15
14 13
14 14
14 15
14 16
15 14
15 15
15 16
15 17
16 15
16 ...

result:

ok correct

Subtask #3:

score: 10
Accepted

Test #5:

score: 10
Accepted
time: 307ms
memory: 11344kb

input:

100 10000 1000 340
87490023455826213450979333037504606824522062808297739018786336978222089712660133428564103979384831
874900289913204769749000879539227331559680630241808944569515663934025397982898503777823815274323967
8749002899116133353924895735921513229471979456689635148877567298640178774668643967...

output:

1000
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 2
3 3
3 4
3 5
4 3
4 4
4 5
4 6
5 4
5 5
5 6
5 7
6 5
6 6
6 7
6 8
7 6
7 7
7 8
7 9
8 7
8 8
8 9
8 10
9 8
9 9
9 10
9 11
10 9
10 10
10 11
10 12
11 10
11 11
11 12
11 13
12 11
12 12
12 13
12 14
13 12
13 13
13 14
13 15
14 13
14 14
14 15
14 16
15 14
15 15
15 16
15 17
16 15
16 ...

result:

ok correct

Test #6:

score: 0
Accepted
time: 312ms
memory: 11540kb

input:

100 10000 1000 340
8748936149282545611299720421204578485624739530690115026507467181657344327662766924981916612956258303
8714827106557313136171687656546075434718184787427526246530142735325290665843132579235229445895749631
8749002377650837755861570823748389228611868494396845969260163830921683752297192...

output:

1000
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 2
3 3
3 4
3 5
4 3
4 4
4 5
4 6
5 4
5 5
5 6
5 7
6 5
6 6
6 7
6 8
7 6
7 7
7 8
7 9
8 7
8 8
8 9
8 10
9 8
9 9
9 10
9 11
10 9
10 10
10 11
10 12
11 10
11 11
11 12
11 13
12 11
12 12
12 13
12 14
13 12
13 13
13 14
13 15
14 13
14 14
14 15
14 16
15 14
15 15
15 16
15 17
16 15
16 ...

result:

ok correct

Subtask #4:

score: 10
Accepted

Test #7:

score: 10
Accepted
time: 326ms
memory: 13620kb

input:

100 10000 990 310
4083451712318559926139496762164571032902328806667934236880329773320213539959944736095945843081512968
7811890641057562314768022152641517082686481268288006737090208624016586608183953908313798353213188661
97358161226180890688421784730819518002666166790210320310558753031161862165361257...

output:

990
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 2
3 3
3 4
3 5
4 3
4 4
4 5
4 6
5 4
5 5
5 6
5 7
6 5
6 6
6 7
6 8
7 6
7 7
7 8
7 9
8 7
8 8
8 9
8 10
9 8
9 9
9 10
9 11
10 9
10 10
10 11
10 12
11 10
11 11
11 12
11 13
12 11
12 12
12 13
12 14
13 12
13 13
13 14
13 15
14 13
14 14
14 15
14 16
15 14
15 15
15 16
15 17
16 15
16 1...

result:

ok correct

Test #8:

score: 0
Accepted
time: 304ms
memory: 11604kb

input:

100 10000 990 310
536242740270410789572341652869398338093269589584059146826540461135298742334471009085914940446278287
4201975342869797382342066007535560618192359692007374881623572540610172361008282611340412383037024069
963134484370112575147508066354646119797740257454037562403391582920830075099761880...

output:

990
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 2
3 3
3 4
3 5
4 3
4 4
4 5
4 6
5 4
5 5
5 6
5 7
6 5
6 6
6 7
6 8
7 6
7 7
7 8
7 9
8 7
8 8
8 9
8 10
9 8
9 9
9 10
9 11
10 9
10 10
10 11
10 12
11 10
11 11
11 12
11 13
12 11
12 12
12 13
12 14
13 12
13 13
13 14
13 15
14 13
14 14
14 15
14 16
15 14
15 15
15 16
15 17
16 15
16 1...

result:

ok correct

Subtask #5:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 307ms
memory: 11820kb

input:

100 10000 1050 260
8749002899132047697490008908470485461412677723566863434996575047286849703722697797645542008396185599
8749002899132047697490008908470485461412677699052921091826559946707718798046219210886366418022957055
7655377536740541735303757766642121742076255665128332760334129720709510994307378...

output:

1050
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 2
3 3
3 4
3 5
4 3
4 4
4 5
4 6
5 4
5 5
5 6
5 7
6 5
6 6
6 7
6 8
7 6
7 7
7 8
7 9
8 7
8 8
8 9
8 10
9 8
9 9
9 10
9 11
10 9
10 10
10 11
10 12
11 10
11 11
11 12
11 13
12 11
12 12
12 13
12 14
13 12
13 13
13 14
13 15
14 13
14 14
14 15
14 16
15 14
15 15
15 16
15 17
16 15
16 ...

result:

wrong answer Wrong[0]

Subtask #6:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 412ms
memory: 11464kb

input:

100 10000 1050 240
8749002899132047697490008908470485461412677723572849734285100881333676956761384191490477496469520383
874886939179415873527191365288672777702448917037688119492655525651250910013304087281579324577152991
87490028991320476974900089084704854614126777235728490149522637601883528949454159...

output:

1050
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 2
3 3
3 4
3 5
4 3
4 4
4 5
4 6
5 4
5 5
5 6
5 7
6 5
6 6
6 7
6 8
7 6
7 7
7 8
7 9
8 7
8 8
8 9
8 10
9 8
9 9
9 10
9 11
10 9
10 10
10 11
10 12
11 10
11 11
11 12
11 13
12 11
12 12
12 13
12 14
13 12
13 13
13 14
13 15
14 13
14 14
14 15
14 16
15 14
15 15
15 16
15 17
16 15
16 ...

result:

wrong answer Wrong[0]

Subtask #7:

score: 20
Accepted

Test #13:

score: 20
Accepted
time: 1ms
memory: 3036kb

input:

100 1 980 260
8749002899132047697490008908470485461309833682610292204604841418296589481615503153703163411103219711

output:

980
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 2
3 3
3 4
3 5
4 3
4 4
4 5
4 6
5 4
5 5
5 6
5 7
6 5
6 6
6 7
6 8
7 6
7 7
7 8
7 9
8 7
8 8
8 9
8 10
9 8
9 9
9 10
9 11
10 9
10 10
10 11
10 12
11 10
11 11
11 12
11 13
12 11
12 12
12 13
12 14
13 12
13 13
13 14
13 15
14 13
14 14
14 15
14 16
15 14
15 15
15 16
15 17
16 15
16 1...

result:

ok correct

Test #14:

score: 0
Accepted
time: 1ms
memory: 3136kb

input:

100 1 980 260
26140399507039494187363454808469075954177491358550589658445256177636481188801043146566104810349008

output:

980
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 2
3 3
3 4
3 5
4 3
4 4
4 5
4 6
5 4
5 5
5 6
5 7
6 5
6 6
6 7
6 8
7 6
7 7
7 8
7 9
8 7
8 8
8 9
8 10
9 8
9 9
9 10
9 11
10 9
10 10
10 11
10 12
11 10
11 11
11 12
11 13
12 11
12 12
12 13
12 14
13 12
13 13
13 14
13 15
14 13
14 14
14 15
14 16
15 14
15 15
15 16
15 17
16 15
16 1...

result:

ok correct

Test #15:

score: 0
Accepted
time: 1ms
memory: 3136kb

input:

100 1 980 260
2916334299201423571746379638671656065302994540964775389402649871877310689655011516150737480170427669

output:

980
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 2
3 3
3 4
3 5
4 3
4 4
4 5
4 6
5 4
5 5
5 6
5 7
6 5
6 6
6 7
6 8
7 6
7 7
7 8
7 9
8 7
8 8
8 9
8 10
9 8
9 9
9 10
9 11
10 9
10 10
10 11
10 12
11 10
11 11
11 12
11 13
12 11
12 12
12 13
12 14
13 12
13 13
13 14
13 15
14 13
14 14
14 15
14 16
15 14
15 15
15 16
15 17
16 15
16 1...

result:

ok correct

Test #16:

score: 0
Accepted
time: 1ms
memory: 2944kb

input:

100 1 980 260
133733063818254349335501779590031438654517135520213587361323145147457390997763303065570586431533875

output:

980
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 2
3 3
3 4
3 5
4 3
4 4
4 5
4 6
5 4
5 5
5 6
5 7
6 5
6 6
6 7
6 8
7 6
7 7
7 8
7 9
8 7
8 8
8 9
8 10
9 8
9 9
9 10
9 11
10 9
10 10
10 11
10 12
11 10
11 11
11 12
11 13
12 11
12 12
12 13
12 14
13 12
13 13
13 14
13 15
14 13
14 14
14 15
14 16
15 14
15 15
15 16
15 17
16 15
16 1...

result:

ok correct

Test #17:

score: 0
Accepted
time: 1ms
memory: 3040kb

input:

100 1 980 260
9216845717656874712980450562726202415567360565980794777111390850331644813674856981646960226192287360

output:

980
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 2
3 3
3 4
3 5
4 3
4 4
4 5
4 6
5 4
5 5
5 6
5 7
6 5
6 6
6 7
6 8
7 6
7 7
7 8
7 9
8 7
8 8
8 9
8 10
9 8
9 9
9 10
9 11
10 9
10 10
10 11
10 12
11 10
11 11
11 12
11 13
12 11
12 12
12 13
12 14
13 12
13 13
13 14
13 15
14 13
14 14
14 15
14 16
15 14
15 15
15 16
15 17
16 15
16 1...

result:

ok correct

Test #18:

score: 0
Accepted
time: 1ms
memory: 2968kb

input:

100 1 980 260
5264952002436106359851318041422054633517706683530105573021775026464088057584242164048188378737906836

output:

980
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 2
3 3
3 4
3 5
4 3
4 4
4 5
4 6
5 4
5 5
5 6
5 7
6 5
6 6
6 7
6 8
7 6
7 7
7 8
7 9
8 7
8 8
8 9
8 10
9 8
9 9
9 10
9 11
10 9
10 10
10 11
10 12
11 10
11 11
11 12
11 13
12 11
12 12
12 13
12 14
13 12
13 13
13 14
13 15
14 13
14 14
14 15
14 16
15 14
15 15
15 16
15 17
16 15
16 1...

result:

ok correct

Subtask #8:

score: 25
Accepted

Test #19:

score: 25
Accepted
time: 290ms
memory: 11400kb

input:

100 10000 960 240
8749002899132047697015724510954438324957730968977252383122989921226002617013223698533483281626692607
8749002899132047697490008908470485461412677720507858663971304708923117942496885325656574463725010943
87148271065573131361716885470369961093519598137825155235803895087505468828694702...

output:

960
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 2
3 3
3 4
3 5
4 3
4 4
4 5
4 6
5 4
5 5
5 6
5 7
6 5
6 6
6 7
6 8
7 6
7 7
7 8
7 9
8 7
8 8
8 9
8 10
9 8
9 9
9 10
9 11
10 9
10 10
10 11
10 12
11 10
11 11
11 12
11 13
12 11
12 12
12 13
12 14
13 12
13 13
13 14
13 15
14 13
14 14
14 15
14 16
15 14
15 15
15 16
15 17
16 15
16 1...

result:

ok correct

Test #20:

score: 0
Accepted
time: 302ms
memory: 11876kb

input:

100 10000 960 240
87490028991320476974751875210481089883984606374917376934978638676026103357677379577201035900354559
874900289913204769748997996044817613236382183082659757372611910814364558665649382849850729809805311
87490028979301854287209922417527640508689863212316623120229713820718860216280007473...

output:

960
1 1
1 2
1 3
2 1
2 2
2 3
2 4
3 2
3 3
3 4
3 5
4 3
4 4
4 5
4 6
5 4
5 5
5 6
5 7
6 5
6 6
6 7
6 8
7 6
7 7
7 8
7 9
8 7
8 8
8 9
8 10
9 8
9 9
9 10
9 11
10 9
10 10
10 11
10 12
11 10
11 11
11 12
11 13
12 11
12 12
12 13
12 14
13 12
13 13
13 14
13 15
14 13
14 14
14 15
14 16
15 14
15 15
15 16
15 17
16 15
16 1...

result:

ok correct