有人能帮我康康错误吗,求

P2249 【深基13.例1】查找

kyv542 @ 2023-12-23 23:55:55

n,m=map(int,input().split()) n1=input().split() m1=input().split() i=0 j=len(n1)-1 k1=0 ans='' for k in m1: while i<=j: m=(i+j)//2 if k<n1[m]: j=m-1 elif k>=n1[m]: i=m+1 while n1[j]==k and n1[j]==n1[j-1]: j=j-1 if n1[j]==k: ans=ans+str(j+1) else: ans+='-1' i=0 print(ans) while i!=len(ans): if ans[i]!='-': print(int(ans[i]),end=' ') i+=1 elif ans[i]=='-': print(int(ans[i:i+2]),end=' ') i=i+2


by lan_chance @ 2023-12-24 00:32:21

建议使用洛谷的代码块功能再发

如:

#include<bits/stdc++.h>
using namespace std;
int main(){

  return 0;
  }

by kyv542 @ 2023-12-31 23:19:34

@lan_chance 谢谢,我再试试


by kyv542 @ 2023-12-31 23:20:39

@lan_chance n,m=map(int,input().split()) n1=input().split() m1=input().split() i=0 j=len(n1)-1 k1=0 ans='' for k in m1: while i<=j: m=(i+j)//2 if k<n1[m]: j=m-1 elif k>=n1[m]: i=m+1 while n1[j]==k and n1[j]==n1[j-1]: j=j-1 if n1[j]==k: ans=ans+str(j+1) else: ans+='-1' i=0 print(ans) while i!=len(ans): if ans[i]!='-': print(int(ans[i]),end=' ') i+=1 elif ans[i]=='-': print(int(ans[i:i+2]),end=' ') i=i+2


by kyv542 @ 2023-12-31 23:24:18

@lan_chance https://cdn.luogu.com.cn/upload/image_hosting/wipb9at8.png


by kyv542 @ 2023-12-31 23:29:53

@lan_chance 请问那个模块怎么使用? 等(: > )


by lan_chance @ 2024-01-01 00:16:25

@kyv542 将代码块展示出来

1.选择插入代码
2.在插入代码中复制代码然后点确定
就行了
或者
如下:
```cpp
最后加```
注意换行

|