답안 #364199

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
364199 2021-02-08T11:32:48 Z Andyvanh1 Alternating Current (BOI18_alternating) C++14
0 / 100
32 ms 3808 KB
using namespace std;


// 17.4.1.2 Headers

// C


#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
int nn;
bool check(vector<pair<int,int>> vt){
    int n = vt.size();

    if(vt[0].first!=1){
        return false;
    }

    for(int i = 1; i < n; i++){
        if(vt[i].first>vt[i-1].second+1){
            return false;
        }
    }
    return true;

}

void solve(){
   int m;
   cin>>nn>>m;
   vector<pair<pair<int,int>,int>> ps;
   for(int i = 0; i < m; i++){
       int a, b;
       cin>>a>>b;
       ps.push_back({{a,b},i});
   }
   sort(ps.begin(),ps.end());
   vector<pair<int,int>> as;
   vector<pair<int,int>> bs;
   int maxA = 0;
   int maxB = 0;
   vector<int> ans(m);
   for(int i = 0; i < m; i++){
       if(maxA>maxB){
           bs.push_back(ps[i].first);
           maxB = max(maxB, ps[i].first.second);
           ans[ps[i].second] = 1;
       }else{
           as.push_back(ps[i].first);
           maxA = max(maxA,ps[i].first.second);
           ans[ps[i].second] = 0;
       }
   }
   if(check(as)&&check(bs)&&maxA==nn&& maxB==nn){
       for(int i = 0; i < m; i++){
           cout<<ans[i];
       }
   }else{
       cout<<"impossible";
   }

}



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);





    int tc = 1;
//read(tc);

    while(tc--) {
        //write("Case #", i+1, ": ");
        solve();

    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 3808 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 12 ms 2020 KB Output is correct
4 Incorrect 12 ms 2020 KB 'impossible' claimed, but there is a solution
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -