제출 #1321438

#제출 시각아이디문제언어결과실행 시간메모리
1321438modwwe장난감 기차 (IOI17_train)C++20
100 / 100
180 ms1240 KiB
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
//#define int long long
#define ll int
#define ull unsigned long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task2 "top1apio"
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define mask(k) (1ll<<k)
#define checktime   cerr <<  (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
#define getchar_unlocked getchar
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
using i128 = __int128;
int rand(int l, int r)
{
    return uniform_int_distribution<int>(l, r)(rd);
}
void phongbeo();
const int inf = 1e17;
const int mod2 = 998244353;
//const ll base=67;
ll  n, m, s1, s2, s4, s3, sf, k, s5, s6, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2,
                                                               r2, center;
ll  i, s10, s12, k1, k2, k3, s11, w, l, r, dem5, dem6, dem7, dem9, root,q;
ll el = 19;
vector<int> ans,a,rv[5001],vc;
bool ok[5001],vis[5001];
int deg[5001],cnt[5001];
bool work()
{
    stack<int> s;
    for(int i=0; i<n; i++)vis[i]=0,cnt[i]=0;
    for(auto x:vc)
        s.push(x),vis[x]=1;
    while(!s.empty())
    {
        int x=s.top();
        s.pop();
        for(auto f:rv[x]){
        cnt[f]++;
            if(!vis[f])
            {
                if(a[f]==1)
                {
                    if(cnt[f]==1)
                    {
                        vis[f]=1;
                        s.push(f);
                    }
                }
                else
                {
                    if(cnt[f]==deg[f])
                    {
                        vis[f]=1;
                        s.push(f);
                    }
                }
            }
        }
    }
    bool xc=1;
    for(auto x:vc)
        if(a[x]==1)
        {
            if(cnt[x]==0)
            {
                xc=0;
                ok[x]=1;
            }
        }
        else
        {
            if(cnt[x]<deg[x])
            {
                xc=0;
                ok[x]=1;
            }
        }
    return xc;
}
vector<int> who_wins(vector<int> A,vector<int>R,vector<int> U,vector<int> V)
{
    a=A;
    n=R.size();
    for(int i=0; i<U.size(); i++)
        rv[V[i]].pb(U[i]),
        deg[U[i]]++;
    for(int i=0; i<n; i++)
        if(R[i])vc.pb(i);
    ans.resize(n);
    while(true)
    {
        if(work())break;
        vc.clear();
        for(int i=0; i<n; i++)if(!ok[i]&&R[i])vc.pb(i);
    }
    for(int i=0;i<n;i++)ans[i]=vis[i];
    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

train.cpp:27:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+17' to '2147483647' [-Woverflow]
   27 | const int inf = 1e17;
      |                 ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...