Submission #693148

# Submission time Handle Problem Language Result Execution time Memory
693148 2023-02-02T12:21:54 Z ktkerem Weighting stones (IZhO11_stones) C++17
100 / 100
224 ms 13852 KB
/*#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
#include<bits/stdc++.h>
//typedef int ll;
typedef long long ll;
typedef unsigned long long ull;
#define llll std::pair<ll , ll>
#define pb push_back
#define pf push_front
#define halo cout << "hello" << std::endl
#define fi first
#define sec second
#define all(a) a.begin() , a.end()
const ll limit = 1e18+7; 
const ll ous = 2e5 + 500;
const ll dx[4] = {-1 , 0 , 1 , 0} , dy[4] = {0,1,0,-1};
std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
ll nk;
struct segt{
    std::vector<llll> valt;
    ll N = 0;
    ll prebuild(ll n){
        N = n;
        valt.resize(4 * N + 5);
        return 1;
    }
    void upd(ll nt , llll upd , ll  a = 1 , ll nl = 0 , ll nr = 0){
        if(a== 1){
            nr = N-1;
        }
        if(nt > nr || nt < nl){
            return;
        }
        if(nl == nr){
            valt[a] = upd;
            //std::cout << a << " " << nl << " " << nr  << " " << valt[a].fi << " " << valt[a].sec << "\n";
            return ;
        }
        ll md= (nl + nr)/2;
        //std::cout << nt << "\n";
        segt::upd(nt , upd , a*2 , nl , md);
        segt::upd(nt , upd ,a*2+1,md+1, nr);
        ll nb = std::max(0ll , valt[a*2].fi - valt[a*2+1].sec);
        ll ng = valt[a*2+1].sec - (valt[a*2].fi - nb);;
        valt[a] = {nb + valt[a*2+1].fi , ng + valt[a*2].sec};
        //std::cout << a << " " << nl << " " << nr  << " " << valt[a].fi << " " << valt[a].sec << "\n";
        return;
    }
};
void solve(){
    std::cin >> nk;
    segt a , b;
    a.prebuild(nk);
    b.prebuild(nk);
    for(ll i=0;nk>i;i++){
        ll x , y;std::cin >> x >> y;
        if(y == 1){
            a.upd(x-1 , {0 , 1});
            //std::cout << "\n";
            b.upd(x-1 , {1 , 0});
        }
        else{
            b.upd(x-1 , {0 , 1});
            //std::cout << "\n";
            a.upd(x-1 , {1 , 0});
        }
        /*std::cout << a.valt[1].fi << " " << a.valt[1].sec << "\n";
        std::cout << b.valt[1].fi << " " << b.valt[1].sec << "\n";*/
        if(a.valt[1].fi == 0){
            std::cout << ">\n";
        }
        else if(b.valt[1].fi == 0){
            std::cout << "<\n";
        }
        else{
            std::cout << "?\n";
        }
    }
    return;/**/
}
signed main(){
    //std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);
    ll t=1;
    //std::cin >> t;
    ll o = 1;
    while(t--){ 
        //std::cout << "Case " << o << ": ";
        //o++;
        solve();        
    }
    return 0;
}/**/

Compilation message

stones.cpp:5:78: warning: "/*" within comment [-Wcomment]
    5 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
      |                                                                               
stones.cpp: In function 'int main()':
stones.cpp:88:8: warning: unused variable 'o' [-Wunused-variable]
   88 |     ll o = 1;
      |        ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 304 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 23 ms 1492 KB Output is correct
11 Correct 128 ms 7848 KB Output is correct
12 Correct 193 ms 12468 KB Output is correct
13 Correct 207 ms 13768 KB Output is correct
14 Correct 188 ms 13744 KB Output is correct
15 Correct 195 ms 13740 KB Output is correct
16 Correct 191 ms 13688 KB Output is correct
17 Correct 208 ms 13808 KB Output is correct
18 Correct 192 ms 13748 KB Output is correct
19 Correct 196 ms 13736 KB Output is correct
20 Correct 191 ms 13760 KB Output is correct
21 Correct 224 ms 13788 KB Output is correct
22 Correct 203 ms 13852 KB Output is correct
23 Correct 188 ms 13772 KB Output is correct
24 Correct 220 ms 13776 KB Output is correct
25 Correct 193 ms 13772 KB Output is correct