267
社区成员
发帖
与我相关
我的任务
分享
//1066 图像过滤
#include<iostream>
using namespace std;
#include<vector>
int main() {
int n, m, a, b, r;
cin >> n >> m >> a >> b >> r;
int s;
vector<vector<int>> ve1;
for (int i = 0; i < n; i++) {
vector<int> ve;
for (int j = 0; j < m; j++) {
cin >> s;
if (s >= a && s <= b) {
s = r;
}
ve.push_back(s);
}
ve1.push_back(ve);
}
for (int i = 0; i < ve1.size(); i++) {
for (int j = 0; j < ve1[i].size() - 1; j++) {
printf("%03d ", ve1[i][j]);
}
printf("%03d\n", ve1[i][ve1[i].size() - 1]);
}
}
//1068 万绿丛中一点红
#include<iostream>
using namespace std;
struct zuobiao {
int lie, hang, shu;
}zuobiaos;
#include<vector>
#include<map>
#include<cmath>
int main() {
vector<vector<int>> ve;
int n, m, tol;
cin >> n >> m >> tol;
int a;
vector<zuobiao> ve0 = {};
map<int, bool> ma;
vector<int> ve00;
for (int i = 0; i < n + 2; i++) {
ve00.push_back(-10000);
}
ve.push_back(ve00);
for (int i = 0; i < m; i++) {
vector<int> ve1 = {-10000};
for (int j = 0; j < n; j++) {
cin >> a;
if (ma.find(a) == ma.end()) {
ma[a] = true;
}
else {
ma[a] = false;
}
ve1.push_back(a);
}
ve1.push_back(-10000);
ve.push_back(ve1);
}
ve.push_back(ve00);
for (int i = 1; i < ve.size() - 1; i++) {
for (int j = 1; j < ve[i].size() - 1; j++) {
if (ma[ve[i][j]] == true
&& abs(ve[i - 1][j - 1] - ve[i][j]) > tol
&& abs(ve[i - 1][j] - ve[i][j]) > tol
&& abs(ve[i - 1][j + 1] - ve[i][j]) > tol
&& abs(ve[i][j - 1] - ve[i][j]) > tol
&& abs(ve[i][j + 1] - ve[i][j]) > tol
&& abs(ve[i + 1][j - 1] - ve[i][j]) > tol
&& abs(ve[i + 1][j] - ve[i][j]) > tol
&& abs(ve[i + 1][j + 1] - ve[i][j]) > tol
) {
zuobiaos.hang = i;
zuobiaos.lie = j;
zuobiaos.shu = ve[i][j];
ve0.push_back(zuobiaos);
}
}
}
if (ve0.size() == 0) {
cout << "Not Exist";
}
else if (ve0.size() == 1) {
printf("(%d, %d): %d", ve0[0].lie, ve0[0].hang, ve0[0].shu);
}
else {
cout << "Not Unique";
}
}
//1069 微博转发抽奖
#include<iostream>
using namespace std;
#include<vector>
#include<map>
int main() {
vector<string> ve, ve1;
map<string, bool> ma;
int n, m, s;
cin >> n >> m >> s;
string a;
for (int i = 0; i < n; i++) {
cin >> a;
if (ma.find(a) == ma.end()) {
ma[a] = true;
}
ve.push_back(a);
}
if (ve.size() < s) {
cout << "Keep going...";
}
else {
for (int i = s - 1; i < n;) {
if (ma[ve[i]] == true) {
ve1.push_back(ve[i]);
ma[ve[i]] = false;
i += m;
}
else {
i++;
}
}
}
for (auto j : ve1) {
cout << j << endl;
}
}