답안 #933240

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
933240 2024-02-25T10:02:49 Z injxshn Experimental Charges (NOI19_charges) C++14
18 / 100
113 ms 2512 KB
#include <iostream>
#include<bits/stdc++.h>
using ll = long long int;
// #define INT_MAX = 1e18;
using namespace std;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define printvec(vec) {for(ll i=0;i<vec.size();i++) cout<<vec[i]<<" "; cout<<endl;}
#define inputvec(vec,n) for(ll i=0;i<n;i++){ ll x; cin>>x; vec.pb(x);};
#define inputvecpp(vec,n) for(ll i=0;i<n;i++){ ll x; ll y;cin>>x; cin >> y; vec.pb({x,y});};
#define f first
#define s second
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
ll minv(vector<ll> v){
    if (v.size() == 0) return 0;
    ll mn = v[0];
    for (ll i = 0; i<v.size(); i++){
        mn = min(mn, v[i]);
    }
    return mn;}
ll maxv(vector<ll> v){
    if (v.size() == 0) return 0;
    ll mn = v[0];
    for (ll i = 0; i<v.size(); i++){
        mn = max(mn, v[i]);
    }
    return mn;}
ll sumv(vector<ll> v){
    if (v.size() == 0) return 0;
    ll mn = 0;
    for (ll i = 0; i<v.size(); i++){
        mn+= v[i];
    }
    return mn;}
// ll n;
// void build(vll &a, vll &s, ll i = 0, ll l = 0, ll r = (n-1)){
//     if(l == r) s[i] = a[l];
//     else{
//         int mid = (l+r)/2;
//         build(a,s,i*2+1, l, mid);
//         build(a,s,i*2+2, mid+1, r);
//         s[i] = s[i*2+1] + s[i*2+2];
//     }
// }
// void update(vll &v, vll &s, ll id, ll val, ll l = 0, ll r = n-1, ll i = 0 ){
//     if(id>r or id<l) return;
//     if(l == r) {
//         if(l == id) {
//             s[i] = val;
//             v[id] = val;
//         }
//         return;
//     }
//     int mid = (l+r)/2;
//     update(v, s, id, val, l, mid, i*2+1);
//     update(v, s,id, val, mid+1, r, i*2+2);
//     s[i] = s[i*2+1]+s[i*2+2];}
// ll query(vll &v, vll &s, ll L, ll R, ll l = 0, ll r = n-1, ll i = 0){
//     if (l>=L and r<=R) return s[i];
//     if (l>R or r<L) return 0;
//     int mid = (l+r)/2;
//     return query(v, s, L,R,l,mid, i*2+1)+query(v, s, L,R,mid+1,r, i*2+2);}
// // build(v,s);
// // query(v, s, --b,--c);
// // update(v, s, --b, c)

ll maxdpv(vll v){
    ll x = v.size();
    vll dp(x);
    dp[0] = v[0];
    dp[1] = v[1];
    for (ll i = 2; i<x; i++){
        dp[i] = max(dp[i-1], dp[i-2] + v[i]);
    }
    return maxv(dp);
}
void test_case(){
    ll n,q;
    cin >> n >> q;
    vll v(n, -1);
    for (ll i = 0; i<q; i++){
        char a;
        cin >> a;
        ll p,q;
        cin >> p >> q;
        --p;
        --q;
        if (a == 'Q'){
            if (v[p] == -1 || v[q] == -1){
                cout << "?" << endl;
            }
            else if ((v[p] + v[q])%2 == 0) cout << "R" << endl;
            else cout << "A" << endl;
        }
        else{
            if (a == 'A'){
                if (v[p] == -1 && v[q] == -1){
                    v[p] = 0;
                    v[q] = 1;
                }
                else if (v[p] == -1){
                    v[p] = 1-v[q]%2;
                }
                else if (v[q] == -1){
                    v[q] = 1-v[p]%2;
                }
            }
            else{
                if (v[p] == -1 && v[q] == -1){
                    v[p] = 1;
                    v[q] = 1;
                }
                else if (v[p] == -1){
                    v[p] = v[q];
                }
                else if (v[q] == -1){
                    v[q] = v[p];
                }
            }
        }
    }
}
int main(){
    // ll t;
    // cin >> t;
    // for (ll i = 0; i<t-1; i++){
    //     test_case();
    // }
    test_case();
    return 0;
}

Compilation message

charges.cpp: In function 'll minv(std::vector<long long int>)':
charges.cpp:20:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (ll i = 0; i<v.size(); i++){
      |                    ~^~~~~~~~~
charges.cpp: In function 'll maxv(std::vector<long long int>)':
charges.cpp:27:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for (ll i = 0; i<v.size(); i++){
      |                    ~^~~~~~~~~
charges.cpp: In function 'll sumv(std::vector<long long int>)':
charges.cpp:34:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (ll i = 0; i<v.size(); i++){
      |                    ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 2128 KB Output is correct
2 Correct 70 ms 2072 KB Output is correct
3 Correct 102 ms 2188 KB Output is correct
4 Correct 84 ms 2108 KB Output is correct
5 Correct 75 ms 2084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 101 ms 2388 KB Output is correct
2 Correct 113 ms 2384 KB Output is correct
3 Incorrect 104 ms 2512 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 2392 KB Output is correct
2 Correct 101 ms 2388 KB Output is correct
3 Incorrect 86 ms 2272 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 75 ms 2128 KB Output is correct
7 Correct 70 ms 2072 KB Output is correct
8 Correct 102 ms 2188 KB Output is correct
9 Correct 84 ms 2108 KB Output is correct
10 Correct 75 ms 2084 KB Output is correct
11 Correct 101 ms 2388 KB Output is correct
12 Correct 113 ms 2384 KB Output is correct
13 Incorrect 104 ms 2512 KB Output isn't correct
14 Halted 0 ms 0 KB -