Submission #69077232


Source Code Expand

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=3e5+10;
int s[N],t[N],p[N],du[N];
vector<int> E[N];
int n;
int main(){
    //freopen("1.in","r",stdin);
    //freopen("1.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++) cin>>s[i]>>t[i];
    for(int i=1;i<=n;i++) p[i]=i;
    sort(p+1,p+n+1,[](int a,int b){return s[a]<s[b];});
    bool flg=1;
    for(int i=2;i<=n;i++) if(t[p[i-1]]>t[p[i]]) flg=0;
    if(!flg){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
        for(int i=1;i<n;i++){
            if(t[p[i]]>s[p[i+1]]) E[p[i+1]].push_back(p[i]),du[p[i]]++;
            if(t[p[i+1]]<s[p[i]]) E[p[i]].push_back(p[i+1]),du[p[i+1]]++;
        }
        queue<int> q;vector<int> ans;
        for(int i=1;i<=n;i++) if(!du[i]) q.push(i);
        while(!q.empty()){
            int p=q.front();q.pop();
            ans.push_back(p);
            for(auto ed:E[p]){
                du[ed]--;if(!du[ed]) q.push(ed);
            }
        }
        for(auto ed:ans) cout<<ed<<' ';cout<<endl;
    }
    return 0;
}

Submission Info

Submission Time
Task C - No Collision Moves
User LYLAKIOIAKIOI
Language C++ 20 (gcc 12.2)
Score 600
Code Size 1093 Byte
Status AC
Exec Time 148 ms
Memory 18432 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:34:9: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
   34 |         for(auto ed:ans) cout<<ed<<' ';cout<<endl;
      |         ^~~
Main.cpp:34:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
   34 |         for(auto ed:ans) cout<<ed<<' ';cout<<endl;
      |                                        ^~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 27
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 2 ms 3556 KiB
00_sample_01.txt AC 2 ms 3480 KiB
00_sample_02.txt AC 2 ms 3488 KiB
01_handmade_00.txt AC 2 ms 3504 KiB
01_handmade_01.txt AC 2 ms 3540 KiB
01_handmade_02.txt AC 148 ms 18432 KiB
01_handmade_03.txt AC 147 ms 18336 KiB
01_handmade_04.txt AC 138 ms 15660 KiB
01_handmade_05.txt AC 114 ms 5836 KiB
01_handmade_06.txt AC 147 ms 18248 KiB
01_handmade_07.txt AC 146 ms 18200 KiB
02_random_00.txt AC 105 ms 5768 KiB
02_random_01.txt AC 18 ms 3876 KiB
02_random_02.txt AC 45 ms 4396 KiB
02_random_03.txt AC 113 ms 5852 KiB
02_random_04.txt AC 115 ms 5820 KiB
02_random_05.txt AC 114 ms 5888 KiB
02_random_06.txt AC 114 ms 5968 KiB
02_random_07.txt AC 114 ms 5892 KiB
02_random_08.txt AC 40 ms 7448 KiB
02_random_09.txt AC 24 ms 5928 KiB
02_random_10.txt AC 128 ms 16548 KiB
02_random_11.txt AC 90 ms 12544 KiB
02_random_12.txt AC 148 ms 18204 KiB
02_random_13.txt AC 143 ms 18256 KiB
02_random_14.txt AC 146 ms 18264 KiB
02_random_15.txt AC 145 ms 18268 KiB