QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#466687 | #8832. Daily Disinfection | USP_USP_USP# | Compile Error | / | / | C++20 | 901b | 2024-07-08 02:17:18 | 2024-07-08 02:17:20 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define pb push_back
#define all(v) (v).begin(), (v).end()
void dbg_out() { cerr << endl; }
template<typename H, typename... T>
void dbg_out(H h, T... t) { cerr << ' ' << h; dbg_out(t...); }
#define dbg(...) { cerr << #__VA_ARGS__ << ':'; dbg_out(__VA_ARGS__); }
void solve() {
int n; cin >> n;
string s; cin >> s;
int c1 = count(all(s), '1');
if(s[0] == '0' || s.back() == '0') {
cout << c1 << '\n';
return;
}
for(int i=0;i+1<n;i++) if(s[i] == '0' && s[i+1] == '0') {
cout << c1 << '\n';
return;
}
} int mn = numeric_limits<int>::max();
for(int i=0;i<n;i++) if(s[i] != '0') {
int j = i;
while(j + 1 < n && s[j+1] == '1') j++;
mn = min(mn, j - i + 1);
i = j;
}
cout << c1 + mn << '\n';
signed main() {
ios::sync_with_stdio(false); cin.tie(0);
int t; cin >> t;
while(t--)
solve();
}
Details
answer.code:27:9: error: expected unqualified-id before ‘for’ 27 | for(int i=0;i<n;i++) if(s[i] != '0') { | ^~~ answer.code:27:23: error: ‘n’ was not declared in this scope; did you mean ‘yn’? 27 | for(int i=0;i<n;i++) if(s[i] != '0') { | ^ | yn answer.code:27:23: error: ‘n’ was not declared in this scope; did you mean ‘yn’? 27 | for(int i=0;i<n;i++) if(s[i] != '0') { | ^ | yn answer.code:27:23: error: ‘n’ was not declared in this scope; did you mean ‘yn’? 27 | for(int i=0;i<n;i++) if(s[i] != '0') { | ^ | yn answer.code:27:23: error: ‘n’ was not declared in this scope; did you mean ‘yn’? 27 | for(int i=0;i<n;i++) if(s[i] != '0') { | ^ | yn answer.code:27:23: error: ‘n’ was not declared in this scope; did you mean ‘yn’? 27 | for(int i=0;i<n;i++) if(s[i] != '0') { | ^ | yn answer.code:27:23: error: ‘n’ was not declared in this scope; did you mean ‘yn’? 27 | for(int i=0;i<n;i++) if(s[i] != '0') { | ^ | yn answer.code:27:23: error: ‘n’ was not declared in this scope; did you mean ‘yn’? 27 | for(int i=0;i<n;i++) if(s[i] != '0') { | ^ | yn answer.code:27:23: error: ‘n’ was not declared in this scope; did you mean ‘yn’? 27 | for(int i=0;i<n;i++) if(s[i] != '0') { | ^ | yn answer.code:27:23: error: ‘n’ was not declared in this scope; did you mean ‘yn’? 27 | for(int i=0;i<n;i++) if(s[i] != '0') { | ^ | yn answer.code:27:21: error: ‘i’ does not name a type 27 | for(int i=0;i<n;i++) if(s[i] != '0') { | ^ answer.code:27:25: error: ‘i’ does not name a type 27 | for(int i=0;i<n;i++) if(s[i] != '0') { | ^ answer.code:33:9: error: ‘cout’ does not name a type 33 | cout << c1 + mn << '\n'; | ^~~~