[Gym]2008-2009 ACM-ICPC, NEERC, Moscow Subregional Contest
比赛链接:http://codeforces.com/gym/100861
A模拟,注意两个特殊的缩写。
#include <bits/stdc++.h>
using namespace std; typedef pair<string, string> pss;
const string MSU = "MSU";
const string SCH = "SCH";
const int maxn = ;
map<string, int> school;
int n;
string a, b;
vector<pss> team;
vector<pss> ret; string up(string x) {
int len = x.length();
for(int i = ; i < len; i++) {
if(x[i] >= 'a' && x[i] <= 'z') x[i] = x[i] - 'a' + 'A';
}
return x;
} int main() {
//freopen("in", "r", stdin);
while(~scanf("%d", &n)) {
school.clear(); team.clear(); ret.clear();
for(int i = ; i <= n; i++) {
cin >> a >> b;
team.push_back(pss(a, b));
}
for(int i = ; i < n; i++) {
string tmp = up(team[i].first);
if(team[i].first == SCH) continue;
if(school.find(tmp) == school.end()) {
ret.push_back(team[i]);
school[tmp] = ;
continue;
}
if(team[i].first == MSU) {
if(school[tmp] < ) {
ret.push_back(team[i]);
school[tmp]++;
}
}
else {
if(school[tmp] < ) {
ret.push_back(team[i]);
school[tmp]++;
}
}
}
if(ret.size() <= ) {
printf("%d\n", ret.size());
for(int i = ; i < ret.size(); i++) {
cout << ret[i].first <<" " << ret[i].second << endl;
}
}
else {
printf("%d\n", );
for(int i = ; i < ; i++) {
cout << ret[i].first <<" " << ret[i].second << endl;
}
}
}
return ;
}
B排序+离散化
#include <bits/stdc++.h>
using namespace std; typedef long long LL;
typedef struct F {
int idx;
LL val;
}F;
typedef struct S {
int idx;
int val;
}S;
const int maxn = ;
const int maxm = ;
S s[maxm];
int k;
int n, m;
LL a, b, c;
F f[maxm];
LL ret[maxm]; int h[maxm], hcnt;
int t[maxm], tcnt; bool cmp1(S a, S b) {
if(a.val == b.val) return a.idx < b.idx;
return a.val > b.val;
} bool cmp2(F a, F b) {
if(a.val == b.val) return a.idx < b.idx;
return a.val > b.val;
} int id(int x) {
return lower_bound(h, h+hcnt, x) - h + ;
} int main() {
freopen("in", "r", stdin);
int x;
while(~scanf("%I64d%I64d%I64d%I64d",&f[].val,&a,&b,&c)) {
memset(ret, , sizeof(ret));
k = ; hcnt = , tcnt = ;
for(int i = ; i < maxm; i++) {
s[i].idx = -;
s[i].val = ;
}
scanf("%d%d",&n,&m);
for(int i = ; i <= n; i++) {
for(int j = ; j <= m; j++) {
scanf("%d", &x);
t[tcnt++] = x;
h[hcnt++] = x;
}
}
sort(h, h+hcnt); hcnt = unique(h, h+hcnt) - h;
for(int i = ; i < tcnt; i++) {
if(s[id(t[i])].idx == -) {
k++;
s[id(t[i])].idx = t[i];
}
s[id(t[i])].val++;
}
sort(s+, s+maxm, cmp1);
f[].idx = ;
for(int i = ; i <= k; i++) {
f[i].idx = i;
f[i].val = ((a * f[i-].val + b) % c) + ;
}
sort(f+, f+k+, cmp2);
for(int i = ; i<= k; i++) {
ret[f[i].idx] = s[i].idx;
}
printf("%d\n", k);
for(int i = ; i<= k; i++) {
printf("%I64d%c", ret[i], i == k ? '\n' : ' ');
}
}
return ;
}
C贪心,就像搭积木一样,全是1*1*1的小方块,要想让表面积尽可能小,那就把他们往一个角落堆。比如
3 3
1 2 3 4 5 6 7 8 9这样的数据,那么排出来就是。
9 8 5
7 6 4
3 2 1
这样可以保证遮盖的部分最大。那么只需要找到第一行和第一列的高度,两边加起来乘2就行了。
#include <bits/stdc++.h>
using namespace std; const int maxn = ;
int n, m, k;
int t[maxn*maxn]; int main() {
// freopen("in", "r", stdin);
while(~scanf("%d%d",&m,&n)) {
k = ;
if(m < n) swap(m, n);
for(int i = ; i <= m; i++) {
for(int j = ; j <= n; j++) {
scanf("%d",&t[k++]);
}
}
sort(t, t+k, greater<int>());
int ret = ;
for(int i = ; i < n; i++) {
ret += t[i*i];
ret += t[i*(i+)];
}
for(int i = n; i < m; i++) {
ret += t[i*n];
}
cout << ret * << endl;
}
return ;
}
G首先知道结果为0的情况,那就是小于等于3个点的时候;想要结果为1,那么必然是两两配对出来的新点位置重合。否则可以让任意四个点组成一个四边形,这个时候分别取每边的中点,构成的四边形一定是平行四边形(很好证明)。所以第二次就一定会有交点了(对角线中心)。
#include <bits/stdc++.h>
using namespace std; typedef pair<int,int> pii;
const int maxn = ;
int n;
int x[maxn], y[maxn];
map<pii, bool> s; int main() {
// freopen("in", "r", stdin);
while(~scanf("%d", &n)) {
s.clear();
for(int i = ; i <= n; i++) {
scanf("%d%d",&x[i],&y[i]);
x[i] <<= ; y[i] <<= ;
}
if(n <= ) {
puts("");
continue;
}
bool flag = ;
for(int i = ; i <= n; i++) {
if(flag) break;
for(int j = i+; j <= n; j++) {
int tx = (x[i] + x[j]) / ;
int ty = (y[i] + y[j]) / ;
if(s.find(pii(tx, ty)) != s.end()) {
printf("1\n");
flag = ;
break;
}
s[pii(tx, ty)] = ;
}
}
if(!flag) puts("");
}
return ;
}
L打表找规律,然后就很简单了。
#include <bits/stdc++.h>
using namespace std; const int maxn = ;
bool vis[maxn]; bool lucky(int s) {
int x, y;
x = s % ;
s /= ;
y = s;
int sx = , sy = ;
while(x) {
sx += x % ;
x /= ;
}
while(y) {
sy += y % ;
y /= ;
}
return sx == sy;
} int main() {
memset(vis, , sizeof(vis));
for(int i = ; i <= ; i++) {
vis[i] = lucky(i);
}
int ret = ;
int tmp = ;
int rl ,rh;
int lo;
lo = ;
for(int i = ; i <= ; i++) {
if(vis[i]) {
if(ret < tmp) {
rl = lo;
rh = i - ;
ret = tmp;
}
tmp = ;
lo = i + ;
}
else {
tmp++;
}
}
cout <<ret <<endl;
cout << rl << " " << rh << endl;
}
#include <bits/stdc++.h>
using namespace std; string ret[][] = {
{"",""},
{"",""},
{"",""},
{"",""},
{"",""},
{"",""},
{"",""},
{"",""},
{"",""},
{"",""},
{"",""},
};
int main() {
int n;
while(~scanf("%d", &n)) {
cout << ret[n][] << endl << ret[n][] << endl;
}
}
[Gym]2008-2009 ACM-ICPC, NEERC, Moscow Subregional Contest的更多相关文章
- ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 G. Garden Gathering
Problem G. Garden Gathering Input file: standard input Output file: standard output Time limit: 3 se ...
- ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 D. Delay Time
Problem D. Delay Time Input file: standard input Output file: standard output Time limit: 1 second M ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest
目录 2018-2019 ICPC, NEERC, Southern Subregional Contest (Codeforces 1070) A.Find a Number(BFS) C.Clou ...
- Codeforces 2018-2019 ICPC, NEERC, Southern Subregional Contest
2018-2019 ICPC, NEERC, Southern Subregional Contest 闲谈: 被操哥和男神带飞的一场ACM,第一把做了这么多题,荣幸成为7题队,虽然比赛的时候频频出锅 ...
- 2016 NEERC, Moscow Subregional Contest K. Knights of the Old Republic(Kruskal思想)
2016 NEERC, Moscow Subregional Contest K. Knights of the Old Republic 题意:有一张图,第i个点被占领需要ai个兵,而每个兵传送至该 ...
- ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 K. King’s Rout
K. King's Rout time limit per test 4 seconds memory limit per test 512 megabytes input standard inpu ...
- ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 I. Illegal or Not?
I. Illegal or Not? time limit per test 1 second memory limit per test 512 megabytes input standard i ...
- ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 H. Hashing
H. Hashing time limit per test 1 second memory limit per test 512 megabytes input standard input out ...
- ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 C. Colder-Hotter
C. Colder-Hotter time limit per test 1 second memory limit per test 512 megabytes input standard inp ...
随机推荐
- Openstack的用户登录流程
openstack的用户登录,需要获得集中权限. token 只需要提供用户名和密码即可获得,接口 http://public_url/tokens method:POST body:{"a ...
- 161114、websocket实现心跳重连
心跳重连缘由 在使用websocket过程中,可能会出现网络断开的情况,比如信号不好,或者网络临时性关闭,这时候websocket的连接已经断开, 而浏览器不会执行websocket 的 onclos ...
- Java简单数据类型转换
1. Integer<---String (1) Integer x = new Integer(Integer.parseInt(String)); 2. Integer<--- ...
- mkdir递归创建目录
mkdir递归创建目录 rmdir递归删除目录 -p:父目录为空时,一并进行创建-v:命令执行结果可视化mkdir -pv /tmp/x/y/zrmdir -p /tmp/x/y/z mkdir -p ...
- Hibernate,JPA注解@SecondaryTable
使用类一级的 @SecondaryTable或@SecondaryTables注解可以实现单个实体到多个表的映射. 使用 @Column或者 @JoinColumn注解中的table参数可指定某个列所 ...
- IOS 音频开发文件大小计算
音频基础知识 音频文件计算大小 音频转码 标签(空格分隔): 调查 IOS音频 https://developer.apple.com/library/ios/documentation/MusicA ...
- HDU 1890:Robotic Sort(Splay)
http://acm.hdu.edu.cn/showproblem.php?pid=1890 题意:有一个无序序列,经过不断地翻转,使得最后的序列是一个升序的序列,而且如果相同数字要使在原本序列靠前的 ...
- ecshop发票不能使用出现flow.php on line 723等报错
最模板给客户ecshop网站做编码转换出现个问题,网站在点结算页面出现Warning: Invalid argument supplied for foreach flow.php on line 7 ...
- SlickGrid example 3a: 可编辑单元
可编辑单元支持一列展示多个属性域,可以为编辑单元提供验证,并且自定义验证事件. 代码: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 T ...
- pip命令使用国内pypi镜像源加速在线安装
参考:http://www.cnblogs.com/yudar/p/4444097.html 用easy_install和pip来安装第三方库很方便 它们的原理其实就是从Python的官方源pypi. ...