diff options
author | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2018-12-12 01:10:38 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2018-12-12 01:10:38 +0700 |
commit | 5e48d2ec45a065cc81781995bf461415563da086 (patch) | |
tree | 89c213a2d47bcf7790b3cc4873c81fd8c1ccefc8 | |
parent | 054428243ccb1c0b39c7fdf8faa449ce415789ce (diff) | |
download | cp-5e48d2ec45a065cc81781995bf461415563da086.tar.gz |
maxep is only 25% AC )-:
-rwxr-xr-x | codechef/chfideal.lua | 4 | ||||
-rwxr-xr-x | codechef/chfintro.lua | 3 | ||||
-rw-r--r-- | codechef/intxor.c | 74 | ||||
-rw-r--r-- | codechef/maxep.c | 26 |
4 files changed, 107 insertions, 0 deletions
diff --git a/codechef/chfideal.lua b/codechef/chfideal.lua new file mode 100755 index 0000000..ded95ee --- /dev/null +++ b/codechef/chfideal.lua @@ -0,0 +1,4 @@ +#!/usr/bin/env lua +print(1) +io.flush() +print(io.read('*n') == 2 and 3 or 2) diff --git a/codechef/chfintro.lua b/codechef/chfintro.lua new file mode 100755 index 0000000..571da78 --- /dev/null +++ b/codechef/chfintro.lua @@ -0,0 +1,3 @@ +#!/usr/bin/env lua +local n, r = io.read('*n', '*n') +for i = 1, n do print(io.read('*n') >= r and 'Good boi' or 'Bad boi') end diff --git a/codechef/intxor.c b/codechef/intxor.c new file mode 100644 index 0000000..f914576 --- /dev/null +++ b/codechef/intxor.c @@ -0,0 +1,74 @@ +#include <stdio.h> + +/* For the sake of performance */ +long a[50000], b[50000]; + +void longxor(long n) +{ + long i, all = 0, almost = 0, vacancy = 0; + + for (i = 0; i < n; i++) { + printf("1 %ld %ld %ld\n", + i + 1, (i + 1) % n + 1, (i + 2) % n + 1); + fflush(stdout); + scanf("%ld", b + i); + all ^= b[i]; + } + + for (i = 2 - n % 3; i < n; i += 3) + almost ^= b[i]; + + for (i = 0; i < n; i++) { + a[vacancy] = all ^ almost; + all ^= b[vacancy] ^ b[(vacancy + 1) % n]; + vacancy = (vacancy + 3) % n; + } +} + +void fourxor(long n) +{ + printf("1 %ld %ld %ld\n", n - 2, n - 1, n); + fflush(stdout); + scanf("%ld", b); + printf("1 %ld %ld %ld\n", n - 3, n - 1, n); + fflush(stdout); + scanf("%ld", b + 1); + printf("1 %ld %ld %ld\n", n - 3, n - 2, n); + fflush(stdout); + scanf("%ld", b + 2); + printf("1 %ld %ld %ld\n", n - 3, n - 2, n - 1); + fflush(stdout); + scanf("%ld", b + 3); + + long all = b[0] ^ b[1] ^ b[2] ^ b[3]; + a[n - 4] = all ^ b[0]; + a[n - 3] = all ^ b[1]; + a[n - 2] = all ^ b[2]; + a[n - 1] = all ^ b[3]; +} + +int main() +{ + long t, n, i = 1; + + scanf("%ld", &t); + while (t-- && i == 1) { + scanf("%ld", &n); + if (n % 3) { + longxor(n); + } else { + longxor(n - 4); + fourxor(n); + } + + putchar(50); + for (i = 0; i < n; i++) + printf(" %ld", a[i]); + putchar(10); + fflush(stdout); + + scanf("%ld", &i); + } + + return 0; +} diff --git a/codechef/maxep.c b/codechef/maxep.c new file mode 100644 index 0000000..e92d9df --- /dev/null +++ b/codechef/maxep.c @@ -0,0 +1,26 @@ +#include <stdio.h> + +int main() +{ + long x = 1, y, n; + int b, c, left = 1000; + + scanf("%ld %d", &n, &c); + while (--left >= c && x < n) { + printf("1 %ld\n", y = (x + n) / 2); + fflush(stdout); + + scanf("%d", &b); + if (b) { + puts("2"); + fflush(stdout); + left -= c; + n = y; + } else { + x = y + 1; + } + } + + printf("3 %ld\n", x); + return 0; +} |