답안 #932824

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
932824 2024-02-24T09:42:42 Z Captain_Georgia Football (info1cup20_football) C++17
26 / 100
2000 ms 3728 KB
#include <bits/stdc++.h> 
using namespace std;
 
/// toto -> 1
 
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define io                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define all(a) a.begin(),a.end()
#define rep(k,i,n) for(int k=i;k<n;k++)
#define repp(k,i,n) for(int k=n-1;k>=i;k--)
#define rech(k) for(char k='a';k<='z';k++)
#define SZ(a) (int)a.size()
#define MX(a) *max_element(all(a))
#define MN(a) *min_element(all(a))
#define SM(a) accumulate(all(a),0LL)
#define vi vector<int>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvi vector<vector<int>>
#define fii first
#define see second

template <typename T> inline bool umin(T &a, const T &b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool umax(T &a, const T &b) { if(a < b) { a = b; return 1; } return 0; }

/// toto -> 

long long mod = 1e9 + 7 , modd = 998244353;
 
 
typedef long long ll;
 
void F1(bool res) {
    if(res) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

void open (string s, string f) {
    freopen((s + ".txt").c_str(), "r", stdin);
    freopen((f + ".txt").c_str(), "w", stdout);
}

void openn (string s, string f) {
    freopen(s.c_str(), "r", stdin);
    freopen(f.c_str(), "w", stdout);
}

struct mint{
    ll val;
 
    mint(int64_t v = 0) {
        v %= mod;
        if (v < 0) v += mod;
        val = v;
    }
 
    mint& operator+=(const mint& other) {
        val += other.val;
        if (val >= mod) val -= mod;
        return *this;
    }
 
    mint& operator-=(const mint& other) {
        val += mod - other.val;
        if (val >= mod) val -= mod;
        return *this;
    }
 
    mint& operator*=(const mint& other) {
        val = (int64_t)val * other.val % mod;
        return *this;
    }
 
    mint& operator/=(const mint& other) {
        return *this *= other.inv();
    }
 
    friend mint operator+(mint a, const mint& b) { return a += b; }
    friend mint operator-(mint a, const mint& b) { return a -= b; }
    friend mint operator*(mint a, const mint& b) { return a *= b; }
    friend mint operator/(mint a, const mint& b) { return a /= b; }
 
    mint pow(int64_t exp) const {
        mint a = *this, res = 1;
        while (exp > 0) {
            if (exp & 1)
                res *= a;
            a *= a;
            exp >>= 1;
        }
        return res;
    }
 
    mint inv() const {
        assert(val != 0);
        return pow(mod - 2);
    }
 
    friend ostream& operator<<(ostream& os, const mint& m) {
        return os << m.val;
    }
};
 
ll bp(ll n,ll m){
    if(m == 0){
        return 1;
    }
    if(m == 1){
        return n%mod;
    }
    if(m%2==0){
        return bp(n*n%mod,m/2)%mod;
    }
    return n*bp(n,m-1)%mod;
}
 
 
/// toto -> 3
 
const int N = 3e5 + 2, M = 1e6 + 434, inf = 1e9 + 1;
const ll inff = 1e18;


void solve(){
    int n , k;
    cin >> n >> k;
    vi a(n);
    ll sum = 0;
    rep (i,0,n) {
        cin >> a[i];
        sum += a[i];
    }
    if (sum%2 != 0) {
        cout << 1;
        return;
    }
    rep (bit,1,30) {
        if ((1 << bit) > k) {
            continue;
        }
        vi v = a;
        int ind = 0 , x = bit;
        rep (i,0,n) {
            while (v[i] > 0) {
                if (v[i] >= (1 << x)) {
                    v[i] -= (1 << x);
                }
                else {
                    while (v[i] < (1 << x)) {
                        x --;
                    }
                    v[i] -= (1 << x);
                }
                ind = (1 - ind);
            }
            if (ind == 0) {
                cout << "1";
                return;
            }
        }
    }
    cout << "0";
} 

int32_t main () {

    io;
    
    ll t = 1;
       cin >> t;
    rep (_,1,t+1) {
        cerr << "Start of test case " << _ << "\n";
        ///cout<<"Case #"<<_<<": ";
        solve();
        cerr << "\n";
        cerr << "\n";
    }
    return 0;
 
}

Compilation message

football.cpp: In function 'void open(std::string, std::string)':
football.cpp:49:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |     freopen((s + ".txt").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
football.cpp:50:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |     freopen((f + ".txt").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
football.cpp: In function 'void openn(std::string, std::string)':
football.cpp:54:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |     freopen(s.c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
football.cpp:55:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |     freopen(f.c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 1372 KB Output is correct
2 Correct 22 ms 1372 KB Output is correct
3 Correct 21 ms 1316 KB Output is correct
4 Correct 21 ms 1368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 68 ms 844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 613 ms 3728 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2029 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2054 ms 1352 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2057 ms 1344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2055 ms 1588 KB Time limit exceeded
2 Halted 0 ms 0 KB -