QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#595324 | #9229. Juliet Unifies Ones | ucup-team4975# | Compile Error | / | / | C++14 | 1.2kb | 2024-09-28 13:26:56 | 2024-09-28 13:26:57 |
Judging History
This is the latest submission verdict.
- [2024-09-28 13:26:57]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-09-28 13:26:56]
- Submitted
answer
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<set>
using namespace std;
const int N=60;
int n,cnt,pre[N][2],suf[N][2];
char s[N];
deque<pair<int,char> >q;
pair<int,char>c[N];
inline void solve()
{
scanf("%s",s+1);
n=strlen(s+1);
for(int i=1;i<=n;)
{
int j=i;
while(j+1<=n&&s[j+1]==s[i])j++;
q.push_front(make_pair(j-i+1,s[i]));
i=j+1;
}
if(q.size()&&q.front().second=='0')q.pop_front();
if(q.size()&&q.back().second=='0')q.pop_back();
if(!q.size())
{
puts("0");
return;
}
cnt=0;
for(auto pos:q)
c[++cnt]=pos;
for(int i=1;i<=cnt;i++)
{
if(c[i].second=='0')
pre[i][0]=pre[i-1][0]+c[i].first,
pre[i][1]=pre[i-1][1];
else pre[i][0]=pre[i-1][0],
pre[i][1]=pre[i-1][1]+c[i].first;
}
int ans=1000000000;
for(int i=1;i<=cnt;i++)
for(int j=1;j<=cnt;j++)
if(c[i].second=='1'&&c[j].second=='1')
ans=min(ans,pre[j][0]-pre[i-1][0]+pre[i-1][1]+pre[cnt][1]-pre[j][1]);
printf("%d\n",ans);
for(int i=1;i<=n;i++)
pre[i][0]=pre[i][1]=0;
}
signed main()
{
int T;
//scanf("%d",&T);
T=1;
while(T--)solve();
return 0;
}
詳細信息
answer.code: In function ‘void solve()’: answer.code:19:11: error: ‘strlen’ was not declared in this scope 19 | n=strlen(s+1); | ^~~~~~ answer.code:8:1: note: ‘strlen’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’? 7 | #include<set> +++ |+#include <cstring> 8 | using namespace std; answer.code:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 18 | scanf("%s",s+1); | ~~~~~^~~~~~~~~~