### 1.AC
#include <iostream> #include <string> #include <unordered_map> using namespace std; string find(string str){ unordered_map<char, int> window; unordered_map<char, int> window1; int i = 0; for (; i < str.size(); i++){ char c = str[i]; if (c == 'M') window[c] = 1; if (c == 'T' && window.count('M')) break; } int j = str.size() - 1; for (; j >= 0; j--){ char c = str[j]; if (c == 'T') window1[c] = 1; if (c == 'M' && window1.count('T')) break; } int len = j - i - 1; return str.substr(i+1, len); } int main(){ int n = 0; cin >> n; string s; cin >> s; cout << find(s) << endl; return 0; }### 2. AC
#include<iostream> #include <vector> using namespace std; //vector<vector<int>> nums = {{1,2,3}, {1,2,3}, {1,2,3}}; vector<int> find(vector<vector<int>>& nums, int n){ vector<bool> visted(n, false); vector<int> res; for (int i = 0; i < n; i++){ for (int j = 0; j < n; j++){ if ( !visted[nums[i][j] - 1] ){ visted[nums[i][j] - 1] = true; res.push_back(nums[i][j]); break; } } } return res; } void show(vector<int> res){ int i = 0; for (; i < res.size() -1; i++){ cout << res[i] << " "; } cout << res[i]; } int main(){ int n = 0; cin >> n; vector<vector<int>> nums(n, vector<int>(n, 0)); for (int i = 0; i < n; i++){ for (int j = 0; j < n; j++){ cin >> nums[i][j]; } } vector<int> res = find(nums, n); show(res); return 0; }### 3. 骗分 9%
### 4. 骗分 18%
### 5. 0%
> 麻烦各位帮忙看下这段代码为啥就是通过不了呀。感觉没问题呀,哪里有问题了?
> 麻烦各位帮忙看下这段代码为啥就是通过不了呀。感觉没问题呀,哪里有问题了?
#include <iostream> #include <vector> #include <iostream> using namespace std; int main(){ int n = 0; cin >> n; vector<int> A(n+1, 0); for (int i = 0; i < n; i++) cin >> A[i+1]; // 操作数 int m = 0; cin >> m; // 具体操作方法 vector<vector<int>> opt(m, vector<int>(4, 0)); for (int i = 0; i < m; i++){ cin >> opt[i][0]; if (opt[i][0] == 1){ for (int j = 0; j < 3; j++){ cin >> opt[i][j]; } } else { cin >> opt[i][1]; } } vector<int> B(n, -1); for (int i = 0; i < m; i++){ if (opt[i][0] == 2){ cout << B[opt[i][1]] << endl; } else if (opt[i][0] == 1){ for (int i = opt[i][2]; i < opt[i][2] + opt[i][1]; i++ ){ int j = opt[i][3]; B[j] = A[i]; j++; } } } return 0; }> 麻烦各位帮忙看下这段代码为啥就是通过不了呀。感觉没问题呀,哪里有问题了?
全部评论
(2) 回帖