답안 #945523

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
945523 2024-03-14T03:24:11 Z dugersuren Snake (CEOI08_snake) C++14
컴파일 오류
0 ms 0 KB
#include "snakelib.h"
#include<bits/stdc++.h>
using namespace std;
int k;
char a1, a2;
int main(){
	int l,r,minLen,maxLen,mid1,mid2;
    k= get_speed();
    minLen=1;maxLen=12122;
    l=0;r=12122;    
    for(int i=1;i<=13;++i){
		mid1 = l + (r-l)/3;
		mid2=r - (r-l)/3;
		ask_snake(mid1,mid2,a1,a2);
        if(a1=='f'){
        	if(a2=='f') maxLen=mid2-l,r=mid2+k-1;
        	if(a2=='s')minLen=mid2-mid1+2,maxLen=mid2-l,r=mid2+k;
        	if(a2=='b')minLen=mid2-mid1+3,r+=k;        	
		}
		if(a1=='s'){
			if(a2=='s'){
				tell_length(minLen=r-l+1);
				
				return 0;
			}
			l=mid1;
			if(a2=='f')maxLen=mid2-l,r=mid2+k-1;
			if(a2=='b')maxLen=r-mid1+1,r=mid2+k;
			
		}
		if(a1=='b'){
			l=mid1+1;
			if(a2=='f')maxLen=mid2-mid1-1,r=mid2+k-1;
        	if(a2=='s')maxLen=mid2-mid1,r=mid2+k;
        	if(a2=='b')minLen=r-mid1+1,r+=k;  
		}
    }
    int guess=(maxLen+minLen)/2;
    tell_length(guess);
    return 0;
}

Compilation message

snake.cpp: In function 'int main()':
snake.cpp:14:23: error: invalid conversion from 'char' to 'char*' [-fpermissive]
   14 |   ask_snake(mid1,mid2,a1,a2);
      |                       ^~
      |                       |
      |                       char
In file included from snake.cpp:1:
snakelib.h:7:26: note:   initializing argument 3 of 'void ask_snake(int, int, char*, char*)'
    7 | void ask_snake(int, int, char*, char*);
      |                          ^~~~~
snake.cpp:14:26: error: invalid conversion from 'char' to 'char*' [-fpermissive]
   14 |   ask_snake(mid1,mid2,a1,a2);
      |                          ^~
      |                          |
      |                          char
In file included from snake.cpp:1:
snakelib.h:7:33: note:   initializing argument 4 of 'void ask_snake(int, int, char*, char*)'
    7 | void ask_snake(int, int, char*, char*);
      |                                 ^~~~~