Submission #785773

# Submission time Handle Problem Language Result Execution time Memory
785773 2023-07-17T15:01:02 Z MilosMilutinovic Broken Device (JOI17_broken_device) C++14
100 / 100
31 ms 2684 KB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
string str[] = {"0", "0", "1", "00", "10", "11", "0", "01"};
bool bad[200];
int cnt;
void Anna(int N, long long X, int K, int P[]) {
	cnt = 0;
	for (int i = 0; i < N; i++)
		bad[i] = false;
	for (int i = 0; i < K; i++)
        bad[P[i]] = true;
    long long ptr = 0;
    for (int i = 0; i < N; i += 3) {
        int cnt = bad[i] + bad[i + 1] + bad[i + 2];
        if (cnt >= 2 || ptr >= 64) {
            Set(i, 0);
            Set(i + 1, 0);
            Set(i + 2, 0);
            continue;
        }
        if (cnt == 0) {
			bool found = false;
            for (int j = 1; j <= 7; j++) {
                if (str[j].size() == 1) {
                    continue;
                }
                int bit0 = (X >> ptr & 1);
                int bit1 = (X >> (ptr + 1) & 1);
                if ((str[j][0] - '0') == bit0 && (str[j][1] - '0') == bit1) {
                    Set(i, j >> 2 & 1);
                    Set(i + 1, j >> 1 & 1);
                    Set(i + 2, j >> 0 & 1);
                    found = true;
                    break;
                }
            }
            assert(found);
            ptr += 2;
            continue;
        }
        int f = (bad[i] ? 2 : (bad[i + 1] ? 1 : 0));
        bool found = false;
        for (int j = 1; j <= 7; j++) {
            if (j >> f & 1) {
                continue;
            }
            bool ok = true;
            for (int k = 0; k < (int) str[j].size(); k++) {
                int bit = (X >> (ptr + k) & 1);
                if (bit != (str[j][k] - '0')) {
                    ok = false;
                }
            }
            if (ok) {
				found = true;
                Set(i, j >> 2 & 1);
                Set(i + 1, j >> 1 & 1);
                Set(i + 2, j >> 0 & 1);
                ptr += str[j].size();
                break;
            }
        }
        
    }
    
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
string str[] = {"0", "0", "1", "00", "10", "11", "0", "01"};
long long Bruno(int N, int A[]) {
    long long bit = 0;
    long long ans = 0;
    for (int i = 0; i < N; i += 3) {
        int x = A[i] * 4 + A[i + 1] * 2 + A[i + 2];
        if (x == 0) {
            continue;
        }
        for (int j = 0; j < (int) str[x].size(); j++) {
            int d = (str[x][j] - '0');
            ans += (1LL << bit) * d;
            bit += 1;
        }
        if (bit >= 60) {
			break;
		}
    }
    return ans;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:43:14: warning: variable 'found' set but not used [-Wunused-but-set-variable]
   43 |         bool found = false;
      |              ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 24 ms 2472 KB Output is correct - L* = 40
2 Correct 23 ms 2540 KB Output is correct - L* = 40
3 Correct 23 ms 2684 KB Output is correct - L* = 40
4 Correct 24 ms 2508 KB Output is correct - L* = 40
5 Correct 24 ms 2508 KB Output is correct - L* = 40
6 Correct 27 ms 2612 KB Output is correct - L* = 40
7 Correct 27 ms 2592 KB Output is correct - L* = 40
8 Correct 28 ms 2624 KB Output is correct - L* = 40
9 Correct 27 ms 2604 KB Output is correct - L* = 40
10 Correct 24 ms 2496 KB Output is correct - L* = 40
11 Correct 24 ms 2496 KB Output is correct - L* = 40
12 Correct 24 ms 2528 KB Output is correct - L* = 40
13 Correct 24 ms 2620 KB Output is correct - L* = 40
14 Correct 24 ms 2480 KB Output is correct - L* = 40
15 Correct 28 ms 2508 KB Output is correct - L* = 40
16 Correct 31 ms 2412 KB Output is correct - L* = 40
17 Correct 26 ms 2672 KB Output is correct - L* = 40
18 Correct 28 ms 2568 KB Output is correct - L* = 40
19 Correct 24 ms 2612 KB Output is correct - L* = 40
20 Correct 27 ms 2540 KB Output is correct - L* = 40
21 Correct 24 ms 2496 KB Output is correct - L* = 40
22 Correct 27 ms 2552 KB Output is correct - L* = 40
23 Correct 24 ms 2472 KB Output is correct - L* = 40
24 Correct 24 ms 2476 KB Output is correct - L* = 40
25 Correct 26 ms 2600 KB Output is correct - L* = 40
26 Correct 24 ms 2516 KB Output is correct - L* = 40
27 Correct 24 ms 2596 KB Output is correct - L* = 40
28 Correct 24 ms 2556 KB Output is correct - L* = 40
29 Correct 24 ms 2588 KB Output is correct - L* = 40
30 Correct 24 ms 2608 KB Output is correct - L* = 40
31 Correct 28 ms 2420 KB Output is correct - L* = 40
32 Correct 24 ms 2460 KB Output is correct - L* = 40
33 Correct 24 ms 2512 KB Output is correct - L* = 40
34 Correct 26 ms 2596 KB Output is correct - L* = 40
35 Correct 24 ms 2532 KB Output is correct - L* = 40
36 Correct 24 ms 2548 KB Output is correct - L* = 40
37 Correct 24 ms 2608 KB Output is correct - L* = 40
38 Correct 27 ms 2576 KB Output is correct - L* = 40
39 Correct 27 ms 2476 KB Output is correct - L* = 40
40 Correct 25 ms 2608 KB Output is correct - L* = 40