제출 #338715

#제출 시각아이디문제언어결과실행 시간메모리
338715NicolaAbusaad2014동굴 (IOI13_cave)C++14
컴파일 에러
0 ms0 KiB
/** * Prof.Nicola **/ #include "cave.h" #include <bits/stdc++.h> using namespace std; template<class T>void re(T&x){cin>>x;} template<class T1,class T2> void re(pair<T1,T2>&x){re(x.first);re(x.second);} template<class T>void re(vector<T>&x){for(long i=0;i<x.size();i++){re(x[i]);}} template<class T>void re(deque<T>&x){for(long i=0;i<x.size();i++){re(x[i]);}} template<class T1,class T2> pair<T1,T2> mp(T1&x,T2&z){return make_pair(x,z);} long long n,turn[5001]={}; vector<long>arr; set<long>s; set<long>::iterator t; void con(long l,long r) { t=s.begin(); for(long i=0;i<s.size();i++){ arr[*t]=turn[*t]; t++; } for(long i=0;i<n&&r>=0;i++){ if(!s.count(i)){ if(l){ l--; continue; } arr[i]=(arr[i]^1); r--; } } } long long bin(long long l,long long r,long long x) { long long mid,a[n]; while(l<r){ mid=(l+r)/2; con(l,mid); for(long i=0;i<n;i++){ a[i]=arr[i]; } if(tryCombination(a)==x){ l=mid+1; } else{ con(l,mid); r=mid; } } return l; } void exploreCave(int N) { n=N; arr.resize(n); long sw[n]={},a[n],ans[n]={}; long x; for(long i=0;i<N;i++){ for(long i=0;i<n;i++){ a[i]=arr[i]; } if(tryCombination(a)!=i){ con(0,N-i); } x=bin(0,N-i,i); ans[x]=i; sw[i]=(arr[i]^1); turn[i]=sw[i]; s.insert(x); } answer(sw,ans); }

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

cave.cpp: In function 'void con(long int, long int)':
cave.cpp:20:19: warning: comparison of integer expressions of different signedness: 'long int' and 'std::set<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(long i=0;i<s.size();i++){
      |                  ~^~~~~~~~~
cave.cpp: In function 'long long int bin(long long int, long long int, long long int)':
cave.cpp:44:27: error: cannot convert 'long long int*' to 'int*'
   44 |         if(tryCombination(a)==x){
      |                           ^
      |                           |
      |                           long long int*
In file included from cave.cpp:4:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:63:27: error: cannot convert 'long int*' to 'int*'
   63 |         if(tryCombination(a)!=i){
      |                           ^
      |                           |
      |                           long int*
In file included from cave.cpp:4:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:72:12: error: cannot convert 'long int*' to 'int*'
   72 |     answer(sw,ans);
      |            ^~
      |            |
      |            long int*
In file included from cave.cpp:4:
cave.h:9:17: note:   initializing argument 1 of 'void answer(int*, int*)'
    9 | void answer(int S[], int D[]);
      |             ~~~~^~~