답안 #914482

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914482 2024-01-22T08:58:53 Z Amr Joker (BOI20_joker) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef long double ld;#define S second//#define F first#define all(x) (x).begin(),(x).end()#define sz size()#define Yes cout << "YES" << endl#define No cout << "NO" << endl#define pb(x) push_back(x);#define endl '\n'#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);const int N=3e5+7;ll INF=INT_MAX,mod=1e9+7;int TT=1;ll power(ll x, unsigned int y){    ll res = 1;    x = x; // % mod;    if (x == 0) return 0;    while (y > 0)    {        if (y & 1) res = (res*x)  ; // % mod;        y = y>>1;        x = (x*x) ; // % mod;    }    return res;}ll n , m , q;pair<ll,ll> p[N];pair<ll,ll>  a[N];vector<vector<ll> > qe(N,vector<ll> (3));ll ans[N];ll siz[N];ll cycles = 0;vector<vector<ll>> roll;ll sqr = 4;bool cmp(vector<ll> x, vector<ll> y){    if(x[0]/sqr==y[0]/sqr) return x[1] < y[1];    return x[0]<y[0];}pair<ll,ll> get(ll x){    if(p[x].first==x) return {x,0};    pair<ll,ll> ho = get(p[x].first);    return {ho.first, p[x].second^ho.second};}void nonmerge(vector<ll> v){    ll x= v[0] , y = v[1] , b = v[2];    if(b)    {    siz[y] -= siz[x];    p[x] = {x,0};    return;    }    else    {        pair<ll,ll> paix = get(x);        pair<ll,ll> paiy = get(y);        if(paix.second==paiy.second) cycles--;    }}void merg(ll x, ll y){    pair<ll,ll> paix = get(x);    pair<ll,ll> paiy = get(y);    if(paix.first==paiy.first)    {        if(paix.second==paiy.second) cycles++;        roll.push_back({x,y,0});    }    else    {        ll xx = paix.first , yy = paiy.first;        if(siz[xx]<siz[yy])        {            p[xx] = {yy,(paix.second==paiy.second)};            roll.push_back({xx,yy,1});        }        else        {            p[yy] = {xx,(paix.second==paiy.second)};            roll.push_back({yy,xx,1});        }    }}void solve(){    cin >> n >> m >> q;    sqr = max(2LL,m/int(sqrt(q))); sqr = 3;    for(int i = 1; i <= n; i++) p[i] = {i,0};    for(int i = 1; i <= m; i++) cin >> a[i].first >> a[i].second;    for(int i = 1; i <= q; i++)    {        cin >> qe[i][0] >> qe[i][1];        qe[i][2] = i;    }    sort(qe.begin()+1,qe.begin()+q+1,cmp);    ll st = 0, en = m+1;    for(int i = 1; i <= q; i++)    {        ll l = qe[i][0] , r = qe[i][1];        while(roll.sz&&st>0)        {            //            nonmerge(roll.back());            roll.pop_back();            st--;        }        while(roll.sz&&en<=r)        {            //            nonmerge(roll.back());            roll.pop_back();            en++;        }        while(en>r+1)        {            en--;            merg(a[en].first,a[en].second);            // mege en        }        while(st<l-1)        {            st++;            merg(a[st].first,a[st].second);          //  cout << cycles << endl;            // merge st;        }        //cout << endl;        //for(int i = 1; i <= n; i++) cout << p[i].first << " " << p[i].second << endl;        //cout << l << " " << r << ": " << st << " " << en<< " " << cycles  << endl;         ans[qe[i][2]] = bool(cycles);    }    for(int i = 1; i <= q; i++)    {        if(ans[i]) Yes; else No;    }}int main(){    //freopen("friday.in","r",stdin);    //freopen("friday.out","w",stdout);    fast;    //cin >> TT;    while(TT--)        solve();    return 0;}

Compilation message

Joker.cpp:1:31: warning: extra tokens at end of #include directive
    1 | #include <bits/stdc++.h>using namespace std;typedef long long ll;typedef long double ld;#define S second//#define F first#define all(x) (x).begin(),(x).end()#define sz size()#define Yes cout << "YES" << endl#define No cout << "NO" << endl#define pb(x) push_back(x);#define endl '\n'#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);const int N=3e5+7;ll INF=INT_MAX,mod=1e9+7;int TT=1;ll power(ll x, unsigned int y){    ll res = 1;    x = x; // % mod;    if (x == 0) return 0;    while (y > 0)    {        if (y & 1) res = (res*x)  ; // % mod;        y = y>>1;        x = (x*x) ; // % mod;    }    return res;}ll n , m , q;pair<ll,ll> p[N];pair<ll,ll>  a[N];vector<vector<ll> > qe(N,vector<ll> (3));ll ans[N];ll siz[N];ll cycles = 0;vector<vector<ll>> roll;ll sqr = 4;bool cmp(vector<ll> x, vector<ll> y){    if(x[0]/sqr==y[0]/sqr) return x[1] < y[1];    return x[0]<y[0];}pair<ll,ll> get(ll x){    if(p[x].first==x) return {x,0};    pair<ll,ll> ho = get(p[x].first);    return {ho.first, p[x].second^ho.second};}void nonmerge(vector<ll> v){    ll x= v[0] , y = v[1] , b = v[2];    if(b)    {    siz[y] -= siz[x];    p[x] = {x,0};    return;    }    else    {        pair<ll,ll> paix = get(x);        pair<ll,ll> paiy = get(y);        if(paix.second==paiy.second) cycles--;    }}void merg(ll x, ll y){    pair<ll,ll> paix = get(x);    pair<ll,ll> paiy = get(y);    if(paix.first==paiy.first)    {        if(paix.second==paiy.second) cycles++;        roll.push_back({x,y,0});    }    else    {        ll xx = paix.first , yy = paiy.first;        if(siz[xx]<siz[yy])        {            p[xx] = {yy,(paix.second==paiy.second)};            roll.push_back({xx,yy,1});        }        else        {            p[yy] = {xx,(paix.second==paiy.second)};            roll.push_back({yy,xx,1});        }    }}void solve(){    cin >> n >> m >> q;    sqr = max(2LL,m/int(sqrt(q))); sqr = 3;    for(int i = 1; i <= n; i++) p[i] = {i,0};    for(int i = 1; i <= m; i++) cin >> a[i].first >> a[i].second;    for(int i = 1; i <= q; i++)    {        cin >> qe[i][0] >> qe[i][1];        qe[i][2] = i;    }    sort(qe.begin()+1,qe.begin()+q+1,cmp);    ll st = 0, en = m+1;    for(int i = 1; i <= q; i++)    {        ll l = qe[i][0] , r = qe[i][1];        while(roll.sz&&st>0)        {            //            nonmerge(roll.back());            roll.pop_back();            st--;        }        while(roll.sz&&en<=r)        {            //            nonmerge(roll.back());            roll.pop_back();            en++;        }        while(en>r+1)        {            en--;            merg(a[en].first,a[en].second);            // mege en        }        while(st<l-1)        {            st++;            merg(a[st].first,a[st].second);          //  cout << cycles << endl;            // merge st;        }        //cout << endl;        //for(int i = 1; i <= n; i++) cout << p[i].first << " " << p[i].second << endl;        //cout << l << " " << r << ": " << st << " " << en<< " " << cycles  << endl;         ans[qe[i][2]] = bool(cycles);    }    for(int i = 1; i <= q; i++)    {        if(ans[i]) Yes; else No;    }}int main(){    //freopen("friday.in","r",stdin);    //freopen("friday.out","w",stdout);    fast;    //cin >> TT;    while(TT--)        solve();    return 0;}
      |                               ^~~~~~~~~
Joker.cpp:1:10: fatal error: bits/stdc++.h>usin: No such file or directory
    1 | #include <bits/stdc++.h>using namespace std;typedef long long ll;typedef long double ld;#define S second//#define F first#define all(x) (x).begin(),(x).end()#define sz size()#define Yes cout << "YES" << endl#define No cout << "NO" << endl#define pb(x) push_back(x);#define endl '\n'#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);const int N=3e5+7;ll INF=INT_MAX,mod=1e9+7;int TT=1;ll power(ll x, unsigned int y){    ll res = 1;    x = x; // % mod;    if (x == 0) return 0;    while (y > 0)    {        if (y & 1) res = (res*x)  ; // % mod;        y = y>>1;        x = (x*x) ; // % mod;    }    return res;}ll n , m , q;pair<ll,ll> p[N];pair<ll,ll>  a[N];vector<vector<ll> > qe(N,vector<ll> (3));ll ans[N];ll siz[N];ll cycles = 0;vector<vector<ll>> roll;ll sqr = 4;bool cmp(vector<ll> x, vector<ll> y){    if(x[0]/sqr==y[0]/sqr) return x[1] < y[1];    return x[0]<y[0];}pair<ll,ll> get(ll x){    if(p[x].first==x) return {x,0};    pair<ll,ll> ho = get(p[x].first);    return {ho.first, p[x].second^ho.second};}void nonmerge(vector<ll> v){    ll x= v[0] , y = v[1] , b = v[2];    if(b)    {    siz[y] -= siz[x];    p[x] = {x,0};    return;    }    else    {        pair<ll,ll> paix = get(x);        pair<ll,ll> paiy = get(y);        if(paix.second==paiy.second) cycles--;    }}void merg(ll x, ll y){    pair<ll,ll> paix = get(x);    pair<ll,ll> paiy = get(y);    if(paix.first==paiy.first)    {        if(paix.second==paiy.second) cycles++;        roll.push_back({x,y,0});    }    else    {        ll xx = paix.first , yy = paiy.first;        if(siz[xx]<siz[yy])        {            p[xx] = {yy,(paix.second==paiy.second)};            roll.push_back({xx,yy,1});        }        else        {            p[yy] = {xx,(paix.second==paiy.second)};            roll.push_back({yy,xx,1});        }    }}void solve(){    cin >> n >> m >> q;    sqr = max(2LL,m/int(sqrt(q))); sqr = 3;    for(int i = 1; i <= n; i++) p[i] = {i,0};    for(int i = 1; i <= m; i++) cin >> a[i].first >> a[i].second;    for(int i = 1; i <= q; i++)    {        cin >> qe[i][0] >> qe[i][1];        qe[i][2] = i;    }    sort(qe.begin()+1,qe.begin()+q+1,cmp);    ll st = 0, en = m+1;    for(int i = 1; i <= q; i++)    {        ll l = qe[i][0] , r = qe[i][1];        while(roll.sz&&st>0)        {            //            nonmerge(roll.back());            roll.pop_back();            st--;        }        while(roll.sz&&en<=r)        {            //            nonmerge(roll.back());            roll.pop_back();            en++;        }        while(en>r+1)        {            en--;            merg(a[en].first,a[en].second);            // mege en        }        while(st<l-1)        {            st++;            merg(a[st].first,a[st].second);          //  cout << cycles << endl;            // merge st;        }        //cout << endl;        //for(int i = 1; i <= n; i++) cout << p[i].first << " " << p[i].second << endl;        //cout << l << " " << r << ": " << st << " " << en<< " " << cycles  << endl;         ans[qe[i][2]] = bool(cycles);    }    for(int i = 1; i <= q; i++)    {        if(ans[i]) Yes; else No;    }}int main(){    //freopen("friday.in","r",stdin);    //freopen("friday.out","w",stdout);    fast;    //cin >> TT;    while(TT--)        solve();    return 0;}
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.