TLE 最后一个点

评测结果
编译成功

foo.cpp: In function 'int main()':
foo.cpp:17:7: warning: 'answer' may be used uninitialized in this function [-Wmaybe-uninitialized]
char answer;
^
测试数据 #0: Accepted, time = 0 ms, mem = 560 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 556 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 560 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 560 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 560 KiB, score = 10
测试数据 #5: Accepted, time = 15 ms, mem = 560 KiB, score = 10
测试数据 #6: Accepted, time = 0 ms, mem = 556 KiB, score = 10
测试数据 #7: Accepted, time = 0 ms, mem = 560 KiB, score = 10
测试数据 #8: Accepted, time = 0 ms, mem = 560 KiB, score = 10
测试数据 #9: TimeLimitExceeded, time = 1015 ms, mem = 50352 KiB, score = 0
TimeLimitExceeded, time = 1030 ms, mem = 50352 KiB, score = 90
代码
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
//ifstream cin("vigenere.in",ios :: in);
//ofstream cout("vigenere.out",ios :: out);
int main() {
  ios :: sync_with_stdio(false);
  string k,c;
  getline(cin,k);
  getline(cin,c);
  int t = 0;
  while (k.length() != c.length()) k += k[t++];
  for (int i = 0;i < (int)c.length();i++) {
    int num1 = (k[i] >= 'A' && k[i] <= 'Z') ? k[i]-'A'+1 : k[i]-'a'+1;
    int num2 = (c[i] >= 'A' && c[i] <= 'Z') ? c[i]-'A'+1 : c[i]-'a'+1;
    char answer;
    for (int ch = 1;ch <= 26;ch++)
      if ((num1-1+ch)%26 == num2 || (!((num1-1+ch)%26) && num2 == 26)) {
        answer = ch-1+'A';
        break;
      }
    if (c[i] >= 'A' && c[i] <= 'Z') cout << answer;
    else {
      answer += 32;
      cout << answer;
    }
  }
  return 0;
}

0 条评论

目前还没有评论...

信息

ID
1778
难度
3
分类
模拟 点击显示
标签
递交数
3055
已通过
1491
通过率
49%
被复制
9
上传者