QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#564505 | #8939. Permutation | maxrgby | Compile Error | / | / | C++14 | 1.0kb | 2024-09-15 08:27:06 | 2024-09-15 08:27:06 |
Judging History
This is the latest submission verdict.
- [2024-09-15 08:27:06]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-09-15 08:27:06]
- Submitted
answer
// Source: https://usaco.guide/general/io
#include <bits/stdc++.h>
using namespace std;
double ra = 0.6;
int query(int a, int b){
int ret;
cout << "? " << a << " " << b << endl;
cin >> ret;
return ret;
}
void solve(int n){
int pos = query(1,n);
int l = 1;
int r = n;
while(r-l > 2){
int mid;
if(pos <= l+(r-l)*ra){
mid = r-(r-l)*ra+1;
if(query(l,mid) == pos){
r = mid;
}else{
l = mid+1;
pos = query(l,r);
}
}else{
mid = l+(r-l)*ra;
if(query(mid,r) == pos){
l = mid;
}else{
r = mid-1;
pos = query(l,r);
}
}
}
if(l == r+1){
if(query(l,r) == l){
return r;
}
return l;
}
if(l == pos){
if(query(r-1,r) == r){
return r-1;
}
return r;
}
if(r == pos){
if(query(l,l+1) == l){
return l+1;
}
return l;
}
if(l+1 == query(l,l+1)){
return l;
}
return r;
}
int main() {
int t;
cin >> t;
while(t--){
int n;
cin >> n;
cout << "! " << solve(n) << endl;
}
}
Details
answer.code: In function ‘void solve(int)’: answer.code:41:32: error: return-statement with a value, in function returning ‘void’ [-fpermissive] 41 | return r; | ^ answer.code:43:24: error: return-statement with a value, in function returning ‘void’ [-fpermissive] 43 | return l; | ^ answer.code:47:33: error: return-statement with a value, in function returning ‘void’ [-fpermissive] 47 | return r-1; | ~^~ answer.code:49:24: error: return-statement with a value, in function returning ‘void’ [-fpermissive] 49 | return r; | ^ answer.code:53:33: error: return-statement with a value, in function returning ‘void’ [-fpermissive] 53 | return l+1; | ~^~ answer.code:55:24: error: return-statement with a value, in function returning ‘void’ [-fpermissive] 55 | return l; | ^ answer.code:58:24: error: return-statement with a value, in function returning ‘void’ [-fpermissive] 58 | return l; | ^ answer.code:60:16: error: return-statement with a value, in function returning ‘void’ [-fpermissive] 60 | return r; | ^ answer.code: In function ‘int main()’: answer.code:69:30: error: no match for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’ and ‘void’) 69 | cout << "! " << solve(n) << endl; | ~~~~~~~~~~~~ ^~ ~~~~~~~~ | | | | | void | std::basic_ostream<char> In file included from /usr/include/c++/13/istream:41, from /usr/include/c++/13/sstream:40, from /usr/include/c++/13/complex:45, from /usr/include/c++/13/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127, from answer.code:3: /usr/include/c++/13/ostream:110:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 110 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ^~~~~~~~ /usr/include/c++/13/ostream:110:36: note: no known conversion for argument 1 from ‘void’ to ‘std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)’ {aka ‘std::basic_ostream<char>& (*)(std::basic_ostream<char>&)’} 110 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/ostream:119:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]’ 119 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/13/ostream:119:32: note: no known conversion for argument 1 from ‘void’ to ‘std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)’ {aka ‘std::basic_ios<char>& (*)(std::basic_ios<char>&)’} 119 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/13/ostream:129:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 129 | operator<<(ios_base& (*__pf) (ios_base&)) | ^~~~~~~~ /usr/include/c++/13/ostream:129:30: note: no known conversion for argument 1 from ‘void’ to ‘std::ios_base& (*)(std::ios_base&)’ 129 | operator<<(ios_base& (*__pf) (ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/13/ostream:168:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 168 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/13/ostream:168:23: note: no known conversion for argument 1 from ‘void’ to ‘long int’ 168 | operator<<(long __n) | ~~~~~^~~ /usr/include/c++/13/ostream:172:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char...