QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#457194 | #8832. Daily Disinfection | ucup-team3699# | Compile Error | / | / | C++20 | 700b | 2024-06-29 08:56:53 | 2024-06-29 08:56:54 |
Judging History
answer
using namespace std;
int n;
int cal(string &s){
int f0;
for (int i = 0; i < n; i++){
if(s[i] == '0'){
f0 = i;
break;
}
}
int now = f0 + 1, ans = f0;
f0 = 0;
for (; now < n; now++){
if(s[now] == '1')
ans += now - f0, f0 = now;
else
f0 = now;
}
return ans;
}
void solve(){
string s;
cin >> n >> s;
int ans = cal(s);
reverse(s.begin(), s.end());
ans = min(ans, cal(s));
cout << ans << "\n";
}
signed main(){
ios_base::sync_with_stdio(0), cin.tie(0);
int t = 1;
cin >> t;
while(t--)
solve();
return 0;
}
Details
answer.code:4:9: error: ‘string’ was not declared in this scope 4 | int cal(string &s){ | ^~~~~~ answer.code:1:1: note: ‘std::string’ is defined in header ‘<string>’; did you forget to ‘#include <string>’? +++ |+#include <string> 1 | answer.code:4:17: error: ‘s’ was not declared in this scope 4 | int cal(string &s){ | ^ answer.code: In function ‘void solve()’: answer.code:23:5: error: ‘string’ was not declared in this scope 23 | string s; | ^~~~~~ answer.code:23:5: note: ‘std::string’ is defined in header ‘<string>’; did you forget to ‘#include <string>’? answer.code:24:5: error: ‘cin’ was not declared in this scope 24 | cin >> n >> s; | ^~~ answer.code:1:1: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’? +++ |+#include <iostream> 1 | answer.code:24:17: error: ‘s’ was not declared in this scope 24 | cin >> n >> s; | ^ answer.code:25:18: error: ‘cal’ cannot be used as a function 25 | int ans = cal(s); | ~~~^~~ answer.code:26:5: error: ‘reverse’ was not declared in this scope 26 | reverse(s.begin(), s.end()); | ^~~~~~~ answer.code:27:23: error: ‘cal’ cannot be used as a function 27 | ans = min(ans, cal(s)); | ~~~^~~ answer.code:27:11: error: ‘min’ was not declared in this scope 27 | ans = min(ans, cal(s)); | ^~~ answer.code:28:5: error: ‘cout’ was not declared in this scope 28 | cout << ans << "\n"; | ^~~~ answer.code:28:5: note: ‘std::cout’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’? answer.code: In function ‘int main()’: answer.code:31:5: error: ‘ios_base’ has not been declared 31 | ios_base::sync_with_stdio(0), cin.tie(0); | ^~~~~~~~ answer.code:31:35: error: ‘cin’ was not declared in this scope 31 | ios_base::sync_with_stdio(0), cin.tie(0); | ^~~ answer.code:31:35: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?