分很菜…

以后写题一定记得把题意理清楚了再开始写。

模拟题还是大坑,代码还是写得不够多,代码量一大就写bug。

补题

l1-8 估值一亿的AI核心代码

补题链接:https://pintia.cn/problem-sets/994805046380707840/problems/1111914599412858885

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define ll long long
#define lowbit(x) (x&(-x))
#define PI acos(-1)
#define ms(x,y) memset(x, y, sizeof(x))
using namespace std; const int maxn = 1e4+;
char s[maxn];
char punc[] = "`~!@#$%^&*()_+-={}|[]\\;':\",./<>?";
char canYou[] = "can you"; //
char couldYou[] = "could you"; //
char me[] = "me"; // inline bool isPunc(char c) { for(int i=;punc[i]!='\0';i++) if(c == punc[i]) return true; return false; }
inline bool isCapit(char c) { return c >= 'A' && c <= 'Z'; }
inline bool isSepar(char c) { return (c == ' ') | isPunc(c); }
inline bool isCanYou(int ptr, int lim)
{
for(int i=;canYou[i] != '\0'; i++)
{
if(i+ptr >= lim) return false;
if(s[i+ptr] != canYou[i]) return false;
}
return +ptr >= lim || isSepar(s[+ptr]);
}
inline bool isCouldYou(int ptr, int lim)
{
for(int i=;couldYou[i] != '\0'; i++)
{
if(i+ptr >= lim) return false;
if(s[i+ptr] != couldYou[i]) return false;
}
return +ptr >= lim || isSepar(s[+ptr]);
}
inline bool isMe(int ptr, int lim)
{
for(int i=;me[i] != '\0'; i++)
{
if(i+ptr >= lim) return false;
if(s[i+ptr] != me[i]) return false;
}
return +ptr >= lim || isSepar(s[+ptr]);
} int print(int i, int lim)
{
if(isCanYou(i+, lim))
{
printf("I can");
i += ;
}
else if(isCouldYou(i+, lim))
{
printf("I could");
i += ;
}
else if(isMe(i+, lim))
{
printf("you");
i += ;
}
else if(i+ < lim && s[i+] == 'I' && (i+ >= lim || isSepar(s[i+])))
{
printf("you");
i += ;
}
return i;
} int main()
{
int T;
scanf("%d", &T);
getchar();
while(T--)
{
cin.getline(s, maxn); puts(s);
int len = strlen(s); int tp_begin = -, tp_end = ;
int now_cnt = ;
for(int i=; i<len; i++)
if(s[i] != ' ')
{
tp_begin = i-; break;
}
for(int i=len-; i>=; i--)
if(s[i] != ' ')
{
tp_end = i; break;
} for(int i=tp_begin+; i<=tp_end; i++)
{
if(s[i] == ' ')
{
int j = i+;
while(j <= tp_end && s[j] == ' ') j ++; // i+1~j-1: redundant space
if(!isPunc(s[j]))
s[now_cnt++] = s[i];
i = j-;
}
else
{
if(isCapit(s[i]) && s[i] != 'I') s[i] = s[i] - 'A' + 'a';
else if(s[i] == '?') s[i] = '!';
s[now_cnt ++] = s[i];
}
} s[now_cnt] = '\0'; printf("AI: ");
int i = ;
while(i < now_cnt && s[i] == ' ') i ++; // first un-space
i = print(i-, now_cnt);
for(i=i+;i<now_cnt;i++)
{
if(isSepar(s[i]))
{
printf("%c", s[i]);
i = print(i, now_cnt); }
else printf("%c", s[i]);
} puts("");
}
}

2019 gplt团体程序设计天梯赛总结的更多相关文章

  1. PTA|团体程序设计天梯赛-练习题目题解锦集(C/C++)(持续更新中……)

    PTA|团体程序设计天梯赛-练习题目题解锦集(持续更新中) 实现语言:C/C++:      欢迎各位看官交流讨论.指导题解错误:或者分享更快的方法!! 题目链接:https://pintia.cn/ ...

  2. 团体程序设计天梯赛(CCCC) L3021 神坛 的一些错误做法(目前网上的方法没一个是对的) 和 一些想法

    团体程序设计天梯赛代码.体现代码技巧,比赛技巧.  https://github.com/congmingyige/cccc_code

  3. 团体程序设计天梯赛(CCCC) L3019 代码排版 方法与编译原理密切相关,只有一个测试点段错误

    团体程序设计天梯赛代码.体现代码技巧,比赛技巧.  https://github.com/congmingyige/cccc_code

  4. 团体程序设计天梯赛(CCCC) L3015 球队“食物链” 状态压缩

    团体程序设计天梯赛代码.体现代码技巧,比赛技巧.  https://github.com/congmingyige/cccc_code #include <cstdio> #include ...

  5. 团体程序设计天梯赛(CCCC) L3014 周游世界 BFS证明

    团体程序设计天梯赛代码.体现代码技巧,比赛技巧.  https://github.com/congmingyige/cccc_code

  6. 团体程序设计天梯赛(CCCC) L3013 非常弹的球 不同思路

    团体程序设计天梯赛代码.体现代码技巧,比赛技巧.  https://github.com/congmingyige/cccc_code

  7. 团体程序设计天梯赛(CCCC) L3012 水果忍者 上凸或下凹的证明

    团体程序设计天梯赛代码.体现代码技巧,比赛技巧.  https://github.com/congmingyige/cccc_code #include <cstdio> #include ...

  8. 团体程序设计天梯赛(CCCC) L3009 长城 方法证明

    团体程序设计天梯赛代码.体现代码技巧,比赛技巧.  https://github.com/congmingyige/cccc_code

  9. 树状数组+二分答案查询第k大的数 (团体程序设计天梯赛 L3-002. 堆栈)

    前提是数的范围较小 1 数据范围:O(n) 2 查第k大的数i:log(n)(树状数组查询小于等于i的数目)*log(n)(二分找到i) 3 添加:log(n) (树状数组) 4 删除:log(n) ...

随机推荐

  1. DATASNAP中间件调用带OUTPUT参数的存储过程

    服务端: function TServerMethods1.spExecOut(funcId, sqlId, inParams: OleVariant): OleVariant;var d: Tfrm ...

  2. 优秀软件project师必备的7大特性

    不是每个程序猿都能成为优秀的软件project师. 在过去的6年时间里,我在Ooyala.Quora和now Quip这3个创业公司面试过许很多多挺有发展潜力的"种子选手".他们都 ...

  3. NJUPT JAVA语言 流处理程序设计

    一. 实验目的和要求 实验目的和要求:要求学生能在学习和理解课堂学习内容中JAVA流编程理论的基础上,学习并逐步掌握JAVA流程序的编写和调试,学习依据处理需求对不同流的正确选择使用和组合用法. 实验 ...

  4. [Android]Fragment源代码分析(三) 事务

    Fragment管理中,不得不谈到的就是它的事务管理,它的事务管理写的很的出彩.我们先引入一个简单经常使用的Fragment事务管理代码片段: FragmentTransaction ft = thi ...

  5. 2014腾讯实习生笔试题——define与typedef

    2014腾讯实习生笔试(广州站)第26题填空题: #define MAX_NUM 1000+1 int Temp = Max_NUM*10; 则Temp的值为( ) 答案是:1010, 由于宏定义仅仅 ...

  6. ScheduleJobFactory

    /* * file name: ScheduleJobFactory.java * copyright: Unis Cloud Information Technology Co., Ltd. Cop ...

  7. Caused by: java.lang.UnsatisfiedLinkError: Couldn&#39;t load BaiduMapVOS_v2_1_3: findLibrary returned nu

    在使用百度地图进行开发的时候.假设遇到了 Caused by: java.lang.UnsatisfiedLinkError: Couldn't load BaiduMapVOS_v2_1_3: fi ...

  8. UESTC--1251--谕神的密码(贪心)

     谕神的密码 Time Limit: 1000MS   Memory Limit: 65535KB   64bit IO Format: %lld & %llu Submit Status ...

  9. C++_homework_EraseComment

    顾名思义就是删除程序中的注释,不清楚fsm的机制,完全是自己的思路做. 开头先读取一个字符确定是否到文件结尾,如果读取成功,是换行的话就换行,并继续读取,不是的话,用putback放回缓冲区,并整行读 ...

  10. preg_replace数组的用法

    $string = 'The quick brown fox jumped over the lazy dog.';$patterns = array();$patterns[2] = '/quick ...