제출 #1313280

#제출 시각아이디문제언어결과실행 시간메모리
1313280neonglitchCONSUL (info1cup19_consul)C++20
컴파일 에러
0 ms0 KiB
#include "grader.h" void solve(int n) { /// insert your code /// for example int a[n+2]={0}; for(int i=1;i<=n;i++)a[i]=-1; int lm=n/3; srand(time(0)); for(int ip=0;ip<30;ip++) { int j=rand()%n + 1; while(a[j]!=-1) { j=rand()%n+1; } a[j]=kth(j); if(cnt(a[j])>lm) { say_answer(a[j]); return; } } say_answer(-1); }

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

consul.cpp: In function 'void solve(int)':
consul.cpp:10:15: error: 'time' was not declared in this scope
   10 |         srand(time(0));
      |               ^~~~
consul.cpp:2:1: note: 'time' is defined in header '<ctime>'; did you forget to '#include <ctime>'?
    1 | #include "grader.h"
  +++ |+#include <ctime>
    2 | 
consul.cpp:10:9: error: 'srand' was not declared in this scope
   10 |         srand(time(0));
      |         ^~~~~
consul.cpp:13:23: error: 'rand' was not declared in this scope
   13 |                 int j=rand()%n + 1;
      |                       ^~~~