2019 gplt团体程序设计天梯赛总结
分很菜…

以后写题一定记得把题意理清楚了再开始写。
模拟题还是大坑,代码还是写得不够多,代码量一大就写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团体程序设计天梯赛总结的更多相关文章
- PTA|团体程序设计天梯赛-练习题目题解锦集(C/C++)(持续更新中……)
		
PTA|团体程序设计天梯赛-练习题目题解锦集(持续更新中) 实现语言:C/C++: 欢迎各位看官交流讨论.指导题解错误:或者分享更快的方法!! 题目链接:https://pintia.cn/ ...
 - 团体程序设计天梯赛(CCCC) L3021 神坛 的一些错误做法(目前网上的方法没一个是对的) 和 一些想法
		
团体程序设计天梯赛代码.体现代码技巧,比赛技巧. https://github.com/congmingyige/cccc_code
 - 团体程序设计天梯赛(CCCC) L3019 代码排版 方法与编译原理密切相关,只有一个测试点段错误
		
团体程序设计天梯赛代码.体现代码技巧,比赛技巧. https://github.com/congmingyige/cccc_code
 - 团体程序设计天梯赛(CCCC) L3015 球队“食物链” 状态压缩
		
团体程序设计天梯赛代码.体现代码技巧,比赛技巧. https://github.com/congmingyige/cccc_code #include <cstdio> #include ...
 - 团体程序设计天梯赛(CCCC) L3014 周游世界 BFS证明
		
团体程序设计天梯赛代码.体现代码技巧,比赛技巧. https://github.com/congmingyige/cccc_code
 - 团体程序设计天梯赛(CCCC) L3013 非常弹的球 不同思路
		
团体程序设计天梯赛代码.体现代码技巧,比赛技巧. https://github.com/congmingyige/cccc_code
 - 团体程序设计天梯赛(CCCC) L3012 水果忍者 上凸或下凹的证明
		
团体程序设计天梯赛代码.体现代码技巧,比赛技巧. https://github.com/congmingyige/cccc_code #include <cstdio> #include ...
 - 团体程序设计天梯赛(CCCC) L3009 长城 方法证明
		
团体程序设计天梯赛代码.体现代码技巧,比赛技巧. https://github.com/congmingyige/cccc_code
 - 树状数组+二分答案查询第k大的数 (团体程序设计天梯赛 L3-002. 堆栈)
		
前提是数的范围较小 1 数据范围:O(n) 2 查第k大的数i:log(n)(树状数组查询小于等于i的数目)*log(n)(二分找到i) 3 添加:log(n) (树状数组) 4 删除:log(n) ...
 
随机推荐
- spring与springboot中,如何在static方法里使用自动注入的属性
			
第一步:写注解@Component 使当前类成为一个bean对象.(@Controller,@service都行) 第二步:写个static的变量 第三步:写个@PostConstruct注解注解注释 ...
 - Framebuffer 机制【转】
			
本文转载自:http://blog.csdn.net/paul_liao/article/details/7706477 Framebuffer Framebuffer是Linux系统为显示设备提供的 ...
 - P1228 地毯填补问题(分治)
			
P1228 地毯填补问题(分治) 题目描述 相传在一个古老的阿拉伯国家里,有一座宫殿.宫殿里有个四四方方的格子迷宫,国王选择驸马的方法非常特殊,也非常简单:公主就站在其中一个方格子上,只要谁能用地毯将 ...
 - tflearn mnist 使用MLP 全连接网络一般都会加dropout哇
			
# -*- coding: utf-8 -*- """ Deep Neural Network for MNIST dataset classification task ...
 - sentcms,thinkphp网站管理系统
			
SentCMS网站管理系统是南昌腾速科技有限公司倾力打造的一款简单易用的网站管理系统,SentCMS网站管理系统(下文简称SentCMS)继承了thinkphp5.0的优秀品质,秉承“大道至简”的设计 ...
 - Redis(六)-数据类型
			
Redis支持五种数据类型:string(字符串),hash(哈希),list(列表),set(集合)及zset(sorted set:有序集合). String(字符串) string是redis最 ...
 - A - HQ9+
			
Problem description HQ9+ is a joke programming language which has only four one-character instructio ...
 - YOLO (You Only Look Once)
			
YOLO (You Only Look Once) dl cnn object detection 一.YOLO YOLO是一个实时的目标检测系统.最新的V2版本在Titan X 上可以每秒处理 ...
 - js-常见简单的js判断方法(暂不参考正则)
			
1: 2: 3: 4: 5: 6: 7:
 - SQL Server 一个简单的游标
			
先看一下原表: DECLARE @id INT; DECLARE @name NVARCHAR(100); DECLARE c_department CURSOR FOR SELECT StuID, ...