您的位置:首页 > 其它

Educational Codeforces Round 10

2016-04-10 22:17 453 查看
A:Gabriel and Caterpillar

题意:蜗牛爬树问题;值得一提的是在第n天如果恰好在天黑时爬到END,则恰好整除,不用再+1;

day = (End - Begin - day0)/(12*(up-down))+1;


#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <set>

#define c_false ios_base::sync_with_stdio(false); cin.tie(0)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define zero_(x,y) memset(x , y , sizeof(x))
#define zero(x) memset(x , 0 , sizeof(x))
#define MAX(x) memset(x , 0x3f ,sizeof(x))
#define swa(x,y) {LL s;s=x;x=y;y=s;}
using namespace std ;
#define N 200005
#define lowbit(k) k&(-k)
const double PI = acos(-1.0);
typedef long long LL ;

struct BIT{int l, r, id;};
int bit
,ANS
,n;
BIT num
;
void update(int s, int k){
for(int j = s; j <= n; j +=lowbit(j))
bit[j] += k;
}
int query(int k){
int ans = 0;
for(int i = k; i > 0; i -=lowbit(i))
ans += bit[i];
return ans;
}
bool compL(BIT a, BIT b){return a.l<b.l;}
bool compR(BIT a, BIT b){return a.r<b.r;}
int main(){
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
//ios_base::sync_with_stdio(false); cin.tie(0);
scanf("%d",&n);
for(int i = 1; i <= n; i++){
scanf("%d%d", &num[i].l, &num[i].r);
num[i].id = i;
}
sort(num+1, num+n+1, compR);
//for(int i = 1; i <= n; i++) cout<<num[i].l<<"  "<<num[i].r<<"  "<<num[i].id<<endl;
for(int i = 1; i <= n; i++) num[i].r = i;
sort(num+1, num+n+1, compL);
//for(int i = 1; i <= n; i++) cout<<num[i].l<<"  "<<num[i].r<<"  "<<num[i].id<<endl;
for(int i = n;i>=1; i--){
ANS[num[i].id] = query(num[i].r);
update(num[i].r, 1);
}
for(int i = 1; i <= n; i++) printf("%d\n", ANS[i]);
return 0;
}


View Code

E:Pursuit For Artifacts

思路:强连通分量

智商太低,无法理解,还是滚去看书去了;

题解连接:

http://www.cnblogs.com/Recoder/p/5323546.html

F:Ants on a Circle

思路:先做了poj 1852再说;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: