| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 236697 | Mercenary | Traffic (CEOI11_tra) | C++14 | 1214 ms | 77460 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define taskname "TEST"
#define pb    push_back
#define mp     make_pair
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif
typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 3e5 + 5;
int n , m , A , B;
pair<int,int> a[maxn];
#define x first
#define y second
vector<int> adj[maxn];
vector<int> adj1[maxn];
void enter()
{
    cin >> n >> m >> A >> B;
    for(int i = 1 ; i <= n ; ++i)cin >> a[i].x >> a[i].y;
    for(int i = 1 ; i <= m ; ++i)
    {
        int u , v , k;
        cin >> u >> v >> k;
        adj[u].pb(v);
        adj1[v].pb(u);
        if(k == 2){
            adj[v].pb(u);
            adj1[u].pb(v);
        }
    }
}
bool vis[maxn];
vector<int> st;
void DFS(int u)
{
    vis[u] = 1;
    for(int c : adj[u])
        if(vis[c] == 0)DFS(c);
    st.pb(u);
}
int gr[maxn];
vector<int> mem[maxn];
int nTime = 0;
void DFS1(int u)
{
    gr[u] = nTime;
    for(int c : adj1[u])
        if(gr[c] == 0)
            DFS1(c);
    mem[nTime].pb(u);
}
int Max[maxn] , Min[maxn];
vector<int> vec;
void DFS2(int u)
{
    Min[u] = 1e9 + 1;
    Max[u] = -1;
    vis[u] = 1;
    for(int v : mem[u])
    {
        if(a[v].first == A)
        {
            Max[u] = max(Max[u] , a[v].second);
            Min[u] = min(Min[u] , a[v].second);
            vec.pb(a[v].second);
        }
        for(int c : adj[v])
        {
            if(vis[gr[c]] == 0){
                DFS2(gr[c]);
            }
            Max[u] = max(Max[u] , Max[gr[c]]);
            Min[u] = min(Min[u] , Min[gr[c]]);
        }
    }
}
void solve()
{
    st.reserve(n);
    for(int i = 1 ; i <= n ; ++i)
        if(vis[i] == 0)DFS(i);
    for(int i = n - 1 ;  i >= 0 ; --i)
    {
        if(gr[st[i]] == 0)
        {
            ++nTime;
            DFS1(st[i]);
        }
    }
    fill_n(vis,maxn,0);
    for(int i = 1 ; i <= n ; ++i)
        if(a[i].first == 0 && vis[gr[i]] == 0)DFS2(gr[i]);
    sort(vec.begin(),vec.end());
    vector<pair<int,int>> res;
    for(auto c : vec)debug(c);
    for(int i = 1 ; i <= n ; ++i)
        if(a[i].first == 0){
            res.pb(mp(a[i].second,upper_bound(vec.begin(),vec.end(),Max[gr[i]]) - lower_bound(vec.begin(),vec.end(),Min[gr[i]])));
            debug(i,gr[i],Min[gr[i]],Max[gr[i]]);
        }
    sort(res.begin(),res.end(),greater<ii>());
    for(auto c : res)cout << max(c.second,0) << '\n';
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    enter();
    solve();
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
