Submission #1833

# Submission time Handle Problem Language Result Execution time Memory
1833 2013-07-18T03:35:13 Z alephnull 탐사 (KOI13_probe) C++
Compilation error
0 ms 0 KB
#include <cstdio> 
#include <algorithm> 
#include <utility> 
using namespace std; 
int k,n; 
int num[2000],start[2000],end[2000]; 
int abs(int n){return n>0?n:-n;} 
int check(int idx,const int* ans){ 
    for(int i=0;i<n;i++){ 
        int cnt=0;int cnt2=0; 
        if(start[i]>=idx)break; 
        if(end[i]>=idx-1){ 
            for(int x=start[i];x<=end[i];x++){ 
                if(ans[x]==1)cnt++; 
                if(ans[x]==-1)cnt2++; 
            } 
            if( abs(cnt-num[i]) > cnt2)return 0; 
        } 
    } 
    if(idx==k+1){ 
        for(int i=1;i<=k;i++){ 
            if(ans[i]==0)printf("-"); 
            else printf("#"); 
        } 
        return 1; 
    } 
    int ans1[k+1],ans2[k+1]; 
    for(int i=0;i<k+1;i++)ans1[i]=ans2[i]=ans[i]; 
    ans1[idx]=1;ans2[idx]=0; 
    return check(idx+1,ans1)||check(idx+1,ans2); 
} 
int main(){ 
    int many=1; 
    scanf("%d %d",&k,&n); 
    for(int i=0;i<n;i++){ 
        scanf("%d %d %d",start+i,end+i,num+i); 
    } 
    pair<pair<int,int>,int> intv[n]; 
  
    for(int i=0;i<n;i++)intv[i]=make_pair(make_pair(start[i],end[i]),num[i]); 
    sort(intv,intv+n); 
    for(int i=0;i<n;i++){ 
        start[i]=intv[i].first.first; 
        end[i]=intv[i].first.second; 
        num[i]=intv[i].second; 
    } 
    int ntmp=n; 
    for(int i=1;i<n;i++){ 
        if(start[i]==start[i-1]&&end[i]==end[i-1]){ 
            if(num[i]!=num[i-1]){printf("NONE");return 0;} 
            start[i-1]=end[i-1]=-1; 
            ntmp--; 
        } 
    } 
    int stmp[ntmp],etmp[ntmp],numtmp[ntmp]; 
    int itmp=0; 
    for(int i=0;i<n;i++){ 
        if(start[i]!=-1){ 
            stmp[itmp]=start[i]; 
            etmp[itmp]=end[i]; 
            numtmp[itmp]=num[i]; 
            itmp++; 
        } 
    } 
    for(int i=0;i<ntmp;i++){ 
            start[i]=stmp[i]; 
            end[i]=etmp[i]; 
            num[i]=numtmp[i]; 
    } 
    n=ntmp; 
    int ans[k+1]; 
    for(int i=0;i<k+1;i++)ans[i]=-1; 
    for(int i=0;i<n;i++){ 
        for(int j=0;j<n;j++){ 
            if(start[i]<=start[j] && end[j]<=end[i]){ 
                if(num[i]-num[j]>start[j]-start[i]+end[i]-end[j]){ 
                    printf("NONE"); 
                    return 0; 
                } 
            } 
        } 
    } 
    if(many) 
        if(check(0,ans)==0)printf("NONE"); 
} 

Compilation message

probe.cpp: In function 'int check(int, const int*)':
probe.cpp:12:12: error: reference to 'end' is ambiguous
         if(end[i]>=idx-1){ 
            ^~~
probe.cpp:6:27: note: candidates are: int end [2000]
 int num[2000],start[2000],end[2000]; 
                           ^~~
In file included from /usr/include/c++/7/utility:76:0,
                 from /usr/include/c++/7/algorithm:60,
                 from probe.cpp:2:
/usr/include/c++/7/initializer_list:99:5: note:                 template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^~~
probe.cpp:13:35: error: reference to 'end' is ambiguous
             for(int x=start[i];x<=end[i];x++){ 
                                   ^~~
probe.cpp:6:27: note: candidates are: int end [2000]
 int num[2000],start[2000],end[2000]; 
                           ^~~
In file included from /usr/include/c++/7/utility:76:0,
                 from /usr/include/c++/7/algorithm:60,
                 from probe.cpp:2:
/usr/include/c++/7/initializer_list:99:5: note:                 template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^~~
probe.cpp: In function 'int main()':
probe.cpp:36:34: error: reference to 'end' is ambiguous
         scanf("%d %d %d",start+i,end+i,num+i); 
                                  ^~~
probe.cpp:6:27: note: candidates are: int end [2000]
 int num[2000],start[2000],end[2000]; 
                           ^~~
In file included from /usr/include/c++/7/utility:76:0,
                 from /usr/include/c++/7/algorithm:60,
                 from probe.cpp:2:
/usr/include/c++/7/initializer_list:99:5: note:                 template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^~~
probe.cpp:40:62: error: reference to 'end' is ambiguous
     for(int i=0;i<n;i++)intv[i]=make_pair(make_pair(start[i],end[i]),num[i]); 
                                                              ^~~
probe.cpp:6:27: note: candidates are: int end [2000]
 int num[2000],start[2000],end[2000]; 
                           ^~~
In file included from /usr/include/c++/7/utility:76:0,
                 from /usr/include/c++/7/algorithm:60,
                 from probe.cpp:2:
/usr/include/c++/7/initializer_list:99:5: note:                 template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^~~
probe.cpp:44:9: error: reference to 'end' is ambiguous
         end[i]=intv[i].first.second; 
         ^~~
probe.cpp:6:27: note: candidates are: int end [2000]
 int num[2000],start[2000],end[2000]; 
                           ^~~
In file included from /usr/include/c++/7/utility:76:0,
                 from /usr/include/c++/7/algorithm:60,
                 from probe.cpp:2:
/usr/include/c++/7/initializer_list:99:5: note:                 template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^~~
probe.cpp:49:34: error: reference to 'end' is ambiguous
         if(start[i]==start[i-1]&&end[i]==end[i-1]){ 
                                  ^~~
probe.cpp:6:27: note: candidates are: int end [2000]
 int num[2000],start[2000],end[2000]; 
                           ^~~
In file included from /usr/include/c++/7/utility:76:0,
                 from /usr/include/c++/7/algorithm:60,
                 from probe.cpp:2:
/usr/include/c++/7/initializer_list:99:5: note:                 template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^~~
probe.cpp:49:42: error: reference to 'end' is ambiguous
         if(start[i]==start[i-1]&&end[i]==end[i-1]){ 
                                          ^~~
probe.cpp:6:27: note: candidates are: int end [2000]
 int num[2000],start[2000],end[2000]; 
                           ^~~
In file included from /usr/include/c++/7/utility:76:0,
                 from /usr/include/c++/7/algorithm:60,
                 from probe.cpp:2:
/usr/include/c++/7/initializer_list:99:5: note:                 template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^~~
probe.cpp:51:24: error: reference to 'end' is ambiguous
             start[i-1]=end[i-1]=-1; 
                        ^~~
probe.cpp:6:27: note: candidates are: int end [2000]
 int num[2000],start[2000],end[2000]; 
                           ^~~
In file included from /usr/include/c++/7/utility:76:0,
                 from /usr/include/c++/7/algorithm:60,
                 from probe.cpp:2:
/usr/include/c++/7/initializer_list:99:5: note:                 template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^~~
probe.cpp:60:24: error: reference to 'end' is ambiguous
             etmp[itmp]=end[i]; 
                        ^~~
probe.cpp:6:27: note: candidates are: int end [2000]
 int num[2000],start[2000],end[2000]; 
                           ^~~
In file included from /usr/include/c++/7/utility:76:0,
                 from /usr/include/c++/7/algorithm:60,
                 from probe.cpp:2:
/usr/include/c++/7/initializer_list:99:5: note:                 template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^~~
probe.cpp:67:13: error: reference to 'end' is ambiguous
             end[i]=etmp[i]; 
             ^~~
probe.cpp:6:27: note: candidates are: int end [2000]
 int num[2000],start[2000],end[2000]; 
                           ^~~
In file included from /usr/include/c++/7/utility:76:0,
                 from /usr/include/c++/7/algorithm:60,
                 from probe.cpp:2:
/usr/include/c++/7/initializer_list:99:5: note:                 template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^~~
probe.cpp:75:38: error: reference to 'end' is ambiguous
             if(start[i]<=start[j] && end[j]<=end[i]){ 
                                      ^~~
probe.cpp:6:27: note: candidates are: int end [2000]
 int num[2000],start[2000],end[2000]; 
                           ^~~
In file included from /usr/include/c++/7/utility:76:0,
                 from /usr/include/c++/7/algorithm:60,
                 from probe.cpp:2:
/usr/include/c++/7/initializer_list:99:5: note:                 template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^~~
probe.cpp:75:46: error: reference to 'end' is ambiguous
             if(start[i]<=start[j] && end[j]<=end[i]){ 
                                              ^~~
probe.cpp:6:27: note: candidates are: int end [2000]
 int num[2000],start[2000],end[2000]; 
                           ^~~
In file included from /usr/include/c++/7/utility:76:0,
                 from /usr/include/c++/7/algorithm:60,
                 from probe.cpp:2:
/usr/include/c++/7/initializer_list:99:5: note:                 template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^~~
probe.cpp:76:52: error: reference to 'end' is ambiguous
                 if(num[i]-num[j]>start[j]-start[i]+end[i]-end[j]){ 
                                                    ^~~
probe.cpp:6:27: note: candidates are: int end [2000]
 int num[2000],start[2000],end[2000]; 
                           ^~~
In file included from /usr/include/c++/7/utility:76:0,
                 from /usr/include/c++/7/algorithm:60,
                 from probe.cpp:2:
/usr/include/c++/7/initializer_list:99:5: note:                 template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^~~
probe.cpp:76:59: error: reference to 'end' is ambiguous
                 if(num[i]-num[j]>start[j]-start[i]+end[i]-end[j]){ 
                                                           ^~~
probe.cpp:6:27: note: candidates are: int end [2000]
 int num[2000],start[2000],end[2000]; 
                           ^~~
In file included from /usr/include/c++/7/utility:76:0,
                 from /usr/include/c++/7/algorithm:60,
                 from probe.cpp:2:
/usr/include/c++/7/initializer_list:99:5: note:                 template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^~~
probe.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&k,&n); 
     ~~~~~^~~~~~~~~~~~~~~