ray2060

368

15922191810
sscanf
zwhy
Hollow
guud

h111111
yxc
N1GU
coder2050
zombotany
Juan

Binarysearch

ray2060
30天前

#### 赛后写的

#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
int T;
cin >> T;
while (T -- ) {
int n;
cin >> n;
int last = 0;
while (n -- ) {
int l, r;
cin >> l >> r;
if (max(last, l) > r) {
cout << 0 << ' ';
} else {
cout << max(last, l) << ' ';
last = max(last, l) + 1;
}
}
cout << endl;
}
return 0;
}

ray2060
30天前

#### 线性

#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
int T;
cin >> T;
while (T -- ) {
int l1, r1, l2, r2;
cin >> l1 >> r1 >> l2 >> r2;
int l, r, cnt;
for (l = l1, r = r2, cnt = 0; l != r; cnt ++ ) {
if (cnt % 2 == 0) {
l ++;
} else {
r --;
}
}
cout << l << ' ' << r << endl;
}
return 0;
}

#### 常数

#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
int T;
cin >> T;
while (T -- ) {
int l1, r1, l2, r2;
cin >> l1 >> r1 >> l2 >> r2;
cout << l1 << ' ' << ((l1 == l2) ? r2 : l2) << endl;
}
return 0;
}

ray2060
1个月前
## 错误代码（必填） C++  #include <iostream> #include <cstring> #include <algorithm> using namespace std; int main() { int T; cin >> T; while (T -- ) { int n; cin >> n; for (int i = n; i >= 1; i -- ) { cout << i << ' '; } cout << endl; } return 0; }  ## 错误思路（必填） 倒序输出不就行了吗 ## 错误数据（选填） ### Wrong Answer 输入： T=2 n1=2 n2=5 输出： a1={2, 1} a2={5, 4, 3, 2, 1} 标准输出： a1={2, 1} a2={2, 1, 5, 3, 4} #### 试了四次，全部WA

ray2060
1个月前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
int n;
cin >> n;
while (n -- ) {
int m;
cin >> m;
if (m == 0) {
cout << 0 << ' ';
continue;
}
int res=0;
while (m) {
res ++;
m &= m - 1;
}
cout << res << ' ';
}
return 0;
}

ray2060
1个月前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
int T;
cin >> T;
while (T -- ) {
int n, k;
char ans[110];
char next = 'a';
cin >> n >> k;
for (int i = 0; i < n; i ++ ) {
ans[i] = next;
next ++;
if (next >= 'a' + k) {
next = 'a';
}
}
ans[n] = 0;
printf("%s", ans);
puts("");
}
return 0;
}

ray2060
1个月前
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
int T;
cin >> T;
while (T -- ) {
int n;
cin >> n;
int s;
s = floor(sqrt(n));
if (s * s >= n) cout << 2 * s << endl;
else if (s * (s + 1) >= n) cout << 2 * s + 1 << endl;
else if ((s + 1) * (s + 1) >= n) cout << 2 * s + 2 << endl;
}
return 0;
}

ray2060
1个月前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int get_len(int a[], int n) {
if (n == 1) return 1;
if (is_sorted(a, a + n)) return n;
return max(get_len(a, n >> 1), get_len(a + (n >> 1), n >> 1));
}

int main()
{
int T;
cin >> T;
int a[20], n;
while (T -- ) {
cin >> n;
for (int i = 0; i < n; i ++ ) cin >> a[i];
printf("%d\n", get_len(a, n));
}
return 0;
}

ray2060
1个月前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
int T;
scanf("%d", &T);
while (T -- ) {
int n;
char s[200010];
scanf("%d", &n);
scanf("%s", s);
int res = -1;
for (int i = 0; i < n - 1; i ++ ) {
if (s[i] > s[i + 1]) {
res = i;
break;
}
}
if (res == -1) res = n - 1;
for (int i = 0; i < n; i ++ ) {
if (i != res) printf("%c", s[i]);
}
puts("");
}
return 0;
}

ray2060
1个月前

ray2060
1个月前

### 算法1

#### C++ 代码

#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main() {
int T;
cin >> T;
while (T -- ) {
int a[100010], n;
cin >> n;
int max = 0;
for (int i = 0; i < n; i ++ ) {
cin >> a[i];
if (max < a[i]) max = a[i];
}
int max_res = 0, res = 0;
for (int i = 0; i < n; i ++ ) {
if (max == a[i]) res ++ ;
else res = 0;
if (max_res < res) max_res = res;
}
cout << max_res << endl;
}
return 0;
}