Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
99170 modongtao 字符串的展开 C++ 运行出错 80 0 MS 260 KB 1190 2023-08-22 11:24:43

Tests(8/10):


#include <bits/stdc++.h> using namespace std; int p1, p2, p3, cur=0; string s; char res[1005]; void putChar(char c) { for (int i = 1; i <= p2; i++) { if (p1 == 3) res[cur++] = '*'; else if (p1 == 2 && 'a' <= c && c <= 'z') res[cur++] = c - 'a' + 'A'; else res[cur++] = c; } } void decode2(char s, char e) { for (char i = e-1; i >= s+1; i--) { putChar(i); } } void decode1(char s, char e) { for (char i = s+1; i <= e-1; i++) { putChar(i); } } void decode(char s, char e) { if (s >= e) { res[cur++] = '-'; } else if (p3 == 2) { decode2(s, e); } else { decode1(s, e); } } void check(int pos) { if (pos == 0 || pos == s.size() - 1) { res[cur++] = s[pos]; } else if (s[pos] == '-') { if ('0' <= s[pos-1] && s[pos-1] <= '9' && '0' <= s[pos+1] && s[pos+1] <= '9') decode(s[pos-1], s[pos+1]); else if ('a' <= s[pos-1] && s[pos-1] <= 'z' && 'a' <= s[pos+1] && s[pos+1] <= 'z') decode(s[pos-1], s[pos+1]); else res[cur++] = s[pos]; } else res[cur++] = s[pos]; } int main() { cin >> p1 >> p2 >> p3; cin >> s; for (int i=0; i < s.size(); i++) { check(i); } cout << res << endl; return 0; }


测评信息: