From 5e48d2ec45a065cc81781995bf461415563da086 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Wed, 12 Dec 2018 01:10:38 +0700 Subject: maxep is only 25% AC )-: --- codechef/chfideal.lua | 4 +++ codechef/chfintro.lua | 3 +++ codechef/intxor.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ codechef/maxep.c | 26 ++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100755 codechef/chfideal.lua create mode 100755 codechef/chfintro.lua create mode 100644 codechef/intxor.c create mode 100644 codechef/maxep.c 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 + +/* 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 + +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; +} -- cgit 1.4.1