[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 ...
随机推荐
- web标准
仔细看看所有的前端招聘要求,几乎所有的都要求对web标准有深刻的理解. web标准,是一系列标准的集合.对前端来说,因为网页是由结构.表现和行为组成.对应的就有结构化标准语言,主要包括XHTML和XM ...
- js数组基础知识链接
http://www.cnblogs.com/qiantuwuliang/archive/2011/01/08/1930499.html 小案例: <script language=&quo ...
- mysql笔记02 创建高性能的索引
创建高性能的索引 1. 索引(在MySQL中也叫做"键(key)")是存储引擎用于快速找到记录的一种数据结构. 2. 索引可以包含一个或多个列的值.如果索引包含多个列,那么列的顺序 ...
- django中request对象详解(转载)
django中的request对象详解 Request 我们知道当URLconf文件匹配到用户输入的路径后,会调用对应的view函数,并将 HttpRequest对象 作为第一个参数传入该函数. ...
- HTML5之WebSocket
在HTML5规范中,我最喜欢的Web技术就是正迅速变得流行的WebSocket API.WebSocket提供了一个受欢迎的技术,以替代我们过去几年一直在用的Ajax技术.这个新的API提供了一个方法 ...
- Spring的javaMail邮件发送(带附件)
项目中经常用到邮件功能,在这里简单的做一下笔记,方便日后温习. 首先需要在配置文件jdbc.properties添加: #------------ Mail ------------ mail.smt ...
- JS和CSS的多浏览器兼容(2)
2.Css的浏览器兼容性 方法一,根据不同的浏览器加载不同的css file <!DOCTYPE html> <html> <head> <title> ...
- jq 动态判断设备添加对应meta viewport属性内同
1.常见的单位 dip, dp, px, sp之间的区别: dip: device independent pixels(设备独立像素). 不同设备有不同的显示效果,这个和设备硬件有关,一般我们为了支 ...
- html+css复习之第1篇
1. 保证在火狐浏览器字体<12px,苹果横屏的时候字体显示大小还是12px html { background: #fff; -webkit-text-size-adjust: 100%; - ...
- jdbc连接集合
JDBC里统一的使用方法: Class.for(jdbcDriverName); Connection conn=DriverManager.getConnection(url,u ...