답안 #243119

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
243119 2020-06-30T11:15:17 Z osaaateiasavtnl Broken Device (JOI17_broken_device) C++14
0 / 100
6 ms 384 KB
#include<bits/stdc++.h>
using namespace std;
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';
 
#include "Annalib.h"
 
int sh1[100];
mt19937 rnd1(2007);
 
void Anna( int N, long long X, int K, int P[] ){
 
    for (int i = 0; i < 100; ++i)
        sh1[i] = rnd1()%3;
    
    /*
    for (int i = 0; i < 10; ++i)
        cout << up1[i];
    cout << endl;            
    */
 
    vector <int> tri;
    while (X) {
        tri.app(X%3);
        X /= 3;        
    }
 
    reverse(all(tri));
 
    vector <bool> used(N);
    for (int i = 0; i < K; ++i)
        used[P[i]] = 1;
 
    /*
    cout << "tri : ";
    for (auto e : tri)
        cout << e << ' ';
    cout << endl;
    */
 
    int tryed = 0;
 
    int i = 0, ptr = 0;
    while (i + 1 < N) {
        auto check = [&]() {
            if (ptr == tri.size())
                return false;
            int x = tri[ptr]+1;
            x += sh1[ptr];
            if (x > 3)
                x -= 3;
 
            bool ans = (!used[i] || !(x&1)) && (!used[i+1] || !((x >> 1) & 1));
 
            if ((!used[i] || !used[i+1]) && !ans)
                ++tryed;
 
            return (!used[i] || !(x&1)) && (!used[i+1] || !((x >> 1) & 1));
        };
        if (check()) {
            int x = tri[ptr]+1;
            x += sh1[ptr];
            if (x > 3)
                x -= 3;
            ++ptr;
 
            Set(i, x & 1);
            Set(i + 1, (x >> 1) & 1);
        }   
        else {
            Set(i, 0);
            Set(i + 1, 0);
        }   
        i += 2;
    }   
 
    if (ptr < tri.size() && tryed < 40) {
        exit(1);
    }   
}
#include<bits/stdc++.h>
using namespace std;
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';
 
#include "Brunolib.h"
 
int sh2[100];
mt19937 rnd2(2007);
 
long long Bruno( int N, int A[] ){
 
    for (int i = 0; i < 100; ++i)
        sh2[i] = rnd2()%3;
 
    /*
    for (int i = 0; i < 10; ++i)
        cout << up2[i];
    cout << endl;            
    */
 
    ll ans = 0;
    int ptr = 0;
    for (int i = 0; i < N; i += 2) {
        int add = A[i] + (A[i+1]<<1);
        if (add) {
 
            add -= sh2[ptr];
            if (add < 1)
                add += 3;                
            ++ptr;
 
            --add;
            ans = ans * 3 + add;
        }   
    }
    return ans;
}       

Compilation message

Anna.cpp: In lambda function:
Anna.cpp:54:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (ptr == tri.size())
                 ~~~~^~~~~~~~~~~~~
Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:85:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (ptr < tri.size() && tryed < 40) {
         ~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
2 Runtime error 4 ms 256 KB Execution failed because the return code was nonzero
3 Runtime error 6 ms 384 KB Execution failed because the return code was nonzero
4 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
5 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
6 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
7 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
8 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
9 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
10 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
11 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
12 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
13 Runtime error 4 ms 384 KB Execution failed because the return code was nonzero
14 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
15 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
16 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
17 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
18 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
19 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
20 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
21 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
22 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
23 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
24 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
25 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
26 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
27 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
28 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
29 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
30 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
31 Runtime error 6 ms 384 KB Execution failed because the return code was nonzero
32 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
33 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
34 Runtime error 4 ms 384 KB Execution failed because the return code was nonzero
35 Runtime error 6 ms 384 KB Execution failed because the return code was nonzero
36 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
37 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
38 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
39 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero
40 Runtime error 5 ms 384 KB Execution failed because the return code was nonzero