답안 #749942

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
749942 2023-05-29T02:00:20 Z vjudge1 사육제 (CEOI14_carnival) Java 11
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long
////
using namespace std;
ll n, l, r;
ll ask(ll l, ll r)
{
    cout << "? " << l << " " << r << '\n';
    int res;
    cin >> res;
    return res;
}
int main()
{
    cin >> n;
    l = 1, r = n;
    while(l < r)
    {
        ll ans1 = ask(l,r);
        ll ans2 = ask(l+1,r);
        ll ans3 = ask(l,r-1);
        if(ans1 == ans2 and ans1 == ans3)
        {
            r--;
            l++;
        }
        else if(ans1 != ans2)
        {
            cout << "! " << l;
            return 0;
        }
        else if(ans1 != ans3)
        {
            cout <<"! "<< r;
            return 0;
        }
    }
    return 0;
}

Compilation message

carnival.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
carnival.java:1: error: class, interface, or enum expected
#include <bits/stdc++.h>
         ^
carnival.java:2: error: illegal character: '#'
#define ll long long
^
carnival.java:5: error: class, interface, or enum expected
ll n, l, r;
^
carnival.java:6: error: class, interface, or enum expected
ll ask(ll l, ll r)
^
carnival.java:9: error: class, interface, or enum expected
    int res;
    ^
carnival.java:10: error: class, interface, or enum expected
    cin >> res;
    ^
carnival.java:11: error: class, interface, or enum expected
    return res;
    ^
carnival.java:12: error: class, interface, or enum expected
}
^
carnival.java:16: error: class, interface, or enum expected
    l = 1, r = n;
    ^
carnival.java:17: error: class, interface, or enum expected
    while(l < r)
    ^
carnival.java:20: error: class, interface, or enum expected
        ll ans2 = ask(l+1,r);
        ^
carnival.java:21: error: class, interface, or enum expected
        ll ans3 = ask(l,r-1);
        ^
carnival.java:22: error: class, interface, or enum expected
        if(ans1 == ans2 and ans1 == ans3)
        ^
carnival.java:25: error: class, interface, or enum expected
            l++;
            ^
carnival.java:26: error: class, interface, or enum expected
        }
        ^
carnival.java:30: error: class, interface, or enum expected
            return 0;
            ^
carnival.java:31: error: class, interface, or enum expected
        }
        ^
carnival.java:35: error: class, interface, or enum expected
            return 0;
            ^
carnival.java:36: error: class, interface, or enum expected
        }
        ^
carnival.java:39: error: class, interface, or enum expected
}
^
21 errors