제출 #1033815

#제출 시각아이디문제언어결과실행 시간메모리
1033815shjeong동굴 (IOI13_cave)C++17
컴파일 에러
0 ms0 KiB
#include "cave.h" #include <iostream> #include <algorithm> typedef long long ll; using namespace std; void exploreCave(int N) { int *s = (int*)malloc(N*sizeof(int)); int *ans = (int*)malloc(N*sizeof(int)); //s[i] = j : i번 문은 j번 스위치 / ans[i] = j : i번 스위치는 j vector<bool> vis(N); for(int i = 0 ; i < N ; i++){ int *tmp = (int*)malloc(N*sizeof(int)); memset(tmp,0,sizeof(tmp)); vector<ll> idx; for(int j = 0 ; j < N ; j++){ if(!vis[j])idx.push_back(j); } for(int j = 0 ; j < i ; j++)tmp[s[j]] = ans[s[j]]; ll x = tryCombination(tmp); bool f = (x==i); ll l = -1, r = (int)idx.size(); while(l+1 < r){ ll mid = l+r>>1; for(int i = l+1 ; i <= mid ; i++)tmp[idx[i]] = 0; for(int i = mid+1 ; i < r ; i++)tmp[idx[i]] = 1; ll x = tryCombination(tmp); if((x==i) == f){ if(f==0)r = mid; else l = mid; } else{ if(f==0)l = mid; else r = mid; } } ans[r] = f; s[i] = r; } answer(ans,s); }

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

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:12:9: error: 'memset' was not declared in this scope
   12 |         memset(tmp,0,sizeof(tmp));
      |         ^~~~~~
cave.cpp:4:1: note: 'memset' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
    3 | #include <algorithm>
  +++ |+#include <cstring>
    4 | typedef long long ll;
cave.cpp:22:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   22 |             ll mid = l+r>>1;
      |                      ~^~