no_one

yin yin yin

2.6万

lianxuhanshu
NeonSean
Mandalorian

AndyLZA
WangJY
cqupt_2nd_handsome
24bskr

DinBong-hhh
Bsqaq

YSW_7
aゞ秋风
Noir
gxf
imooo10

no_one
30天前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
const int N = 100010;
long long a[N], a2[N];
int s[N], s2[N];
int n, m;

int main()
{
cin >> n;
for(int i = 1; i <= n; i ++) cin >> a[i], a2[i] = a[i], a[i] += a[i - 1];

sort(a2 + 1, a2 + n + 1);
for(int i = 1; i <= n; i ++) a2[i] += a2[i - 1];

cin >> m;
int op, l, r;
while (m -- )
{
cin >> op >> l >> r;
if(op == 1)
{
cout << a[r] - a[l - 1] << endl;
}
else
{
cout << a2[r] - a2[l - 1] << endl;
}
}

return 0;
}


no_one
30天前
#include<iostream>
#include<algorithm>
#include <unordered_map>

using namespace std;

int main()
{
unordered_map<string, int> op;
int n;
cin >> n;
string b;
getchar();
while(n --)
{
getline(cin, b);
op[b] ++;

}

int res = 0;
for(auto i : op)
{
res = max(res, i.second);
}

cout << res << endl;

return 0;
}


no_one
2个月前
#include <iostream>
#include <cstring>
#include <algorithm>
#include <unordered_set>

using namespace std;

int main()
{
int n;
cin >> n;

unordered_set<string> hash;
while (n -- )
{
string a, b;
cin >> a >> b;
hash.insert(a + ' ' + b);
}

cout << hash.size() << endl;
return 0;
}



no_one
2个月前

## 就这啊

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

using namespace std;

char op[7] = {'R', 'O', 'Y', 'G', 'B', 'I', 'V'};

int main()
{
int n;
cin >> n;

int cnt = 0;
while (n --)
{
if(cnt == 7)
cnt = 3;
cout << op[cnt ++];
}

cout << endl;
return 0;
}


no_one
2个月前

## 好久没做题了哎

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

using namespace std;

int main()
{
int n;
cin >> n;
unordered_map<string, int> cnt;

while(n --)
{
string a;
cin >> a;
cnt[a] ++;
}
string res;
int max = 0;
for(auto a : cnt)
{
if(a.second > max)
{
max = a.second;
res = a.first;
}

}

cout << res << endl;
return 0;
}


no_one
3个月前

# 没啥好说的

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

using namespace std;

int n;
string s;
int a[1020];

int main()
{
cin >> n >> s;
for (int i = 0; i < n; i++)
{
a[i] = 1;
}
for (int j = 0; j < 1000; j++)
{
for (int i = 0; i < n - 1; i++)
{
if (s[i] == '<')
{
a[i + 1] = max(a[i] + 1, a[i + 1]);
}
}
for (int i = n - 2; i >= 0; i--)
{
if (s[i] == '>')
{
a[i] = max(a[i + 1] + 1, a[i]);
}
}
for (int i = 0; i < n; i++)
{
if (s[i] == '=')
{
a[i + 1] = a[i] = max(a[i], a[i + 1]);
}
}
}
for (int i = 0; i < n; i++)
{
cout << a[i] << " ";
}
return 0;
}



no_one
3个月前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
const int N = 15;

char g[N][N][N];
int n, m, k;

int dx[] = {1, 0, 0, -1, 0, 0};
int dy[] = {0, 1, 0, 0, -1, 0};
int dz[] = {0, 0, 1, 0, 0, -1};

int dfs(int x, int y, int z)
{
g[x][y][z] = '#';
int res = 1;

for(int i = 0; i < 6; i ++)
{
int x1 = x + dx[i], y1 = y + dy[i], z1 = z + dz[i];
if(x1 < 0 || x1 >= n || y1 < 0 || y1 >= m || z1 < 0 || z1 >= k) continue;
if (g[x1][y1][z1] == '#') continue;

res += dfs(x1, y1, z1);
}

return res;
}

int main()
{
cin >> n >> m >> k;

for (int i = 0; i < n; i ++ )
for (int j = 0; j < m; j ++ )
cin >> g[i][j];

int y, z;
cin >> y >> z;

cout << dfs(0, y - 1, z - 1) << endl;

return 0;
}


no_one
3个月前

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

using namespace std;
const int N = 1010;

int a[N];

int main()
{
int n;
cin >> n;

for(int i = 0; i < n; i ++) cin >> a[i];

int res = 0x3f3f3f3f;
for(int i = 0; i < n - 1; i ++) res = min(res, abs(a[i + 1] - a[i]));

res = min(res, abs(a[n - 1] - a[0]));
cout << res << endl;

return 0;
}


no_one
3个月前

## 双指针

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

using namespace std;
typedef long long LL;
const int N = 510;
int n, m, k;
int a[N][N], s[N][N];

int main()
{
cin >> n >> m >> k;

for(int i = 1; i <= n ; i ++)
for(int j = 1; j <= m; j ++)
cin >> a[i][j];

for(int i = 1; i <= n ; i ++)
for(int j = 1; j <= m; j ++)
s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j];

LL res = 0;
for (int i = 1; i <= m; i ++ ) // 左边界
for (int j = i; j <= m; j ++ ) // 右边界
for (int u = 1, d = 1; d <= n; d ++ )
{
while (u <= d && s[d][j] - s[u - 1][j] - s[d][i - 1] + s[u - 1][i - 1] > k) u ++ ; // 双指针
if (u <= d) res += d - u + 1; // 更新答案
}

cout << res << endl;

return 0;
}


no_one
3个月前

## 骗分都骗不了

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

using namespace std;
const int N = 510;
int n, m, k;
int a[N][N], s[N][N];

int main()
{
cin >> n >> m >> k;

for(int i = 1; i <= n ; i ++)
for(int j = 1; j <= m; j ++)
cin >> a[i][j];

for(int i = 1; i <= n ; i ++)
for(int j = 1; j <= m; j ++)
s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j];

int res = 0;
for(int x1 = 1; x1 <= n; x1 ++)
for(int y1 = 1; y1 <= m; y1 ++)
for(int x2 = x1; x2 <= n; x2 ++)
for(int y2 = y1; y2 <= m; y2 ++)
if(s[x2][y2] - s[x1 - 1][y2] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1] <= k)
{
res ++;
}

cout << res << endl;

return 0;
}