Submission #863928

# Submission time Handle Problem Language Result Execution time Memory
863928 2023-10-21T13:09:33 Z hariaakas646 Mensza (COI22_mensza) C++17
34 / 100
5000 ms 142456 KB
#include <bits/stdc++.h>

using namespace std;

#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;


void usaco()
{
    freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
//    freopen("problem.out", "w", stdout);
}

int main() {
    // usaco();
    int l, q;
    cin >> l >> q;
    frange(i, q) {
        char c;
        cin >> c;
        char v = c;
        int a;
        frange(i,  7) cin >> v;
        cin >> a;
        // printf("%d\n", a);

        if(c == 'a') {
            vi out;
            frange(i, 10) {
                if(a & (1<<i)) {
                    frange(j, 2*i+1) out.pb(2*i+1);
                }
            }
            printf("%d ", (int)out.size());
            for(auto e : out) printf("%d ", e);
            printf("\n");
        }
        else if(c == 'b') {
            vi out;
            frange(i, 10) {
                if(a & (1<<i)) {
                    frange(j, 2*i+2) out.pb(2*i+2);
                }
            }
            printf("%d ", (int)out.size());
            for(auto e : out) printf("%d ", e);
            printf("\n");
        }
        else {
            int b = 0;
            int c = 0;
            vi vec(a);
            frange(j, a) cin >> vec[j];
            // for(auto e : vec) printf("%d ", e);
            for(int e : vec) {

                if(e % 2) {
                    b = b | (1LL<<((e-1)/2));
                    // printf("%d %d %d\n", e, (1<<((e-1)/2)), b);
                }
                else {
                    c = c | (1LL<<((e-2)/2));
                    // printf("%d %d %d\n", e, (1<<((e-1)/2)), c);
                }
            }
            // printf("%d %d\n", b, c);
            if(b > c) printf("A\n");
            else printf("B\n");
        }
    }
}

Compilation message

Main.cpp: In function 'void usaco()':
Main.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 24 ms 872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2871 ms 3124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5021 ms 142456 KB Time limit exceeded
2 Halted 0 ms 0 KB -