全部TLE……
  • 板块P1765 手机
  • 楼主秋夜Dx
  • 当前回复1
  • 已保存回复1
  • 发布时间2021/1/22 20:50
  • 上次更新2023/11/5 04:32:29
查看原帖
全部TLE……
463591
秋夜Dx楼主2021/1/22 20:50
#include <iostream>
#include <string>
using namespace std;

int main() {
    string str;
    int sum=0;
    char ch;

    getline(cin,str);
    while(str.length()>0)
    {
        sscanf(str.c_str(),"%c",&ch);
        if(ch==' ' || ch=='a' || ch=='d' || ch=='g' || ch=='j' || ch=='m' || ch=='p' || ch=='t' || ch=='w')
        {
            sum++;
            str=str.substr(1,str.length());
            continue;
        }
        if(ch=='b' || ch=='e' || ch=='h' || ch=='k' || ch=='n' || ch=='q' || ch=='u' || ch=='x')
        {
            sum+=2;
            str=str.substr(1,str.length());
            continue;
        }
        if(ch=='c' || ch=='f' || ch=='i' || ch=='l' || ch=='o' || ch=='r' || ch=='v' || ch=='y')
        {
            sum+=3;
            str=str.substr(1,str.length());
            continue;
        }
        if(ch=='s' || ch=='z')
        {
            sum+=4;
            str=str.substr(1,str.length());
            continue;
        }
    }
    cout << sum;
    return 0;
}

555……本地测试没问题,但是提交就全部TLE……用的应该没有错吧qwq 问题在哪儿呢0.0

2021/1/22 20:50
加载中...