总结一下这场。。。

搞起大号就崩了。。。

A题没啥问题。。通过电脑到手机上提交没啥大问题;

B题,讲个最严重的问题,也是最近以来最严重的问题,虽然我说你开了个数组,虽然这个数组是不是最终的答案数组,但是。。还是要考虑这个数组的范围啊,就像图的题目你为啥要注意邻接表结构体数组的大小啊,而且很恶心的是返回的是WA,而不是RE...注意每个变量的数据范围!!!还有就是题目注意点不搞好,i < j 啊!!!哎,wa11wa的整场心态崩掉。。然后C;

C题,本身因为CF卡爆不想打了,呵,CF卡爆是借口吧,主要还是心态。C知道题意,B还不知道pp没...然后C题直接乱搞,直接套强连通。。。虽然是可行的。。然而没求LCM。。。又是题意问题。。F**K! 好吧,D,E后来也没读。。。

打大号感觉真的是好烦,好多次都崩掉。。。都大二第一学期快过去了,还那么菜啊。。。。。。

--------------------------------------------------------

A题:

简单题,好像被HACK0的时候蛮多的,快速幂刚好完美躲避了。。。;

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>PII;
const double eps=1e-5;
const double pi=acos(-1.0);
const int INF=0x3f3f3f3f; const int mod=10; int cal(int g,int x)
{
int ans=1;
while(g)
{
if(g&1)
ans=ans*x%mod;
x=x*x%mod;
g/=2;
}
return ans;
} int main()
{
int n;
scanf("%d",&n);
printf("%d\n",cal(n,8));
return 0;
}

B题:

a^b=c;a^c=b;b^c=a;

求个对数,而且是 i < j,ans还会爆LL;

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>PII;
const double eps=1e-5;
const double pi=acos(-1.0);
const int INF=0x3f3f3f3f; const int N=1e5+10; int n,x;
int a[N];
LL num[5000050];
map<PII,int>mp; int main()
{
scanf("%d%d",&n,&x);
memset(num,0,sizeof(num));
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
num[a[i]]++;
}
int xx,yy;
LL ans=0;
mp.clear();
for(int i=1;i<=n;i++)
{
xx=a[i];
yy=a[i]^x;
if(xx>yy)
swap(xx,yy);
if(mp[{xx,yy}]==0)
{
if(xx!=yy)
ans+=num[xx]*num[yy];
else
ans+=(num[xx]-1)*num[xx]/2;
mp[make_pair(xx,yy)]=1;
}
}
printf("%I64d\n",ans);
return 0;
}

C题:

直接套的是强连通,强连通分量元素只有一个的话且a[u]!=u那就是不满足,然后其实对每个点只有一条边,DFS一下也可以;

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>PII;
const double eps=1e-5;
const double pi=acos(-1.0);
const int INF=0x3f3f3f3f; int n;
const int N=1e4+10;
const int M=5e4+10; struct Node{
int to;
int next;
};
Node edge[M]; //链式前向星
int tol,head[M]; //dfn[v]: 顶点v被访问的时间;
//low[v]: 与顶点v邻接的未删除的顶点u的low[u]和low[v]的最小值,初始时low[v]=dfn[v];
//tp: 访问时间;
//Stack[] : 数组模拟栈,p: 栈的大小;
//vis[]: 顶点是否在栈中
//in[]: 缩点后的数组,cnt: 缩点后图中点的个数
//kt[]: 出度数组
int dfn[N],low[N],tp;
int Stack[N],p;
bool vis[N];
int in[N],cnt;
int kt[N];
int a[N]; int LCM(int xx,int yy)
{
return (xx*yy/__gcd(xx,yy));
} void add(int u,int v)
{
edge[tol].to=v;
edge[tol].next=head[u];
head[u]=tol++;
} void init()
{
//初始化链式前向星
tol=0;
memset(head,-1,sizeof(head));
memset(vis,0,sizeof(vis)); //初始化顶点都不在栈里面
memset(dfn,0,sizeof(dfn)); //初始化访问时间为0
tp=p=0; //初始化时间和栈大小都为0
cnt=0; //缩点初始化,可以理解有cnt种点集
}
int flag;
int ans;
void Tarjan(int u)
{
int v;
dfn[u]=low[u]=++tp; //初始化dfn=low=访问时间 尤其注意这个++tp还是tp++,我们初始化时间是0,所以之后访问到的时间就一定>0;
Stack[++p]=u; //节点入栈
vis[u]=true; //入栈标记 for(int i=head[u];i!=-1;i=edge[i].next)
{
v=edge[i].to;
if(!dfn[v]) //如果还为被访问
{
Tarjan(v);
low[u]=min(low[u],low[v]);
}
else if(vis[v]) //在栈里;
low[u]=min(low[u],dfn[v]);
}
int temp;
int temp_num=0;
if(dfn[u]==low[u]) //如果是这个强连通分量的根;
{
cnt++; //缩点标记
while(1)
{
++temp_num;
temp=Stack[p]; //取元素
vis[temp]=false; //出栈标记
in[temp]=cnt; //缩点
--p;
if(temp==u) //如果与u相等,退出
break;
}
if(temp_num==1)
{
if(a[u]!=u)
flag=false;
}
if(temp_num%2==0)
temp_num/=2;
ans=LCM(ans,temp_num);
}
} int main()
{
int x;
scanf("%d",&n);
init();
int flagflag=false;
for(int i=1;i<=n;i++)
{
scanf("%d",&x);
a[i]=x;
if(x!=i)
flagflag=1;
add(i,x);
}
if(!flagflag)
{
puts("1");
return 0;
}
flag=true;
ans=1;
for(int i=1;i<=n;i++)
{
if(!dfn[i]) //如果还没有被访问过
Tarjan(i);
}
if(!flag)
{
puts("-1");
return 0;
}
printf("%d\n",ans);
return 0;
}

Codeforces Round #383 【总结】的更多相关文章

  1. Codeforces Round #383 (Div. 2) 题解【ABCDE】

    Codeforces Round #383 (Div. 2) A. Arpa's hard exam and Mehrdad's naive cheat 题意 求1378^n mod 10 题解 直接 ...

  2. Codeforces Round #383 (Div. 2) C. Arpa's loud Owf and Mehrdad's evil plan —— DFS找环

    题目链接:http://codeforces.com/contest/742/problem/C C. Arpa's loud Owf and Mehrdad's evil plan time lim ...

  3. Codeforces Round #383 (Div. 2) A,B,C,D 循环节,标记,暴力,并查集+分组背包

    A. Arpa’s hard exam and Mehrdad’s naive cheat time limit per test 1 second memory limit per test 256 ...

  4. dfs + 最小公倍数 Codeforces Round #383 (Div. 2)

    http://codeforces.com/contest/742/problem/C 题目大意:从x出发,从x->f[x] - > f[f[x]] -> f[f[f[x]]] -& ...

  5. 01背包dp+并查集 Codeforces Round #383 (Div. 2)

    http://codeforces.com/contest/742/problem/D 题目大意:有n个人,每个人有重量wi和魅力值bi.然后又有m对朋友关系,朋友关系是传递的,如果a和b是朋友,b和 ...

  6. Codeforces Round #383 Div 1题解

    第一次打Div 1,感觉还是挺难的..把基础题打完就日常划水了.... [A. Arpa's loud Owf and Mehrdad's evil plan](http://codeforces.c ...

  7. Codeforces Round #383 (Div. 2)C. Arpa's loud Owf and Mehrdad's evil plan

    C. Arpa's loud Owf and Mehrdad's evil plan time limit per test 1 second memory limit per test 256 me ...

  8. Codeforces Codeforces Round #383 (Div. 2) E (DFS染色)

    题目链接:http://codeforces.com/contest/742/problem/E 题意: 有一个环形的桌子,一共有n对情侣,2n个人,一共有两种菜. 现在让你输出一种方案,满足以下要求 ...

  9. Codeforces Round #383 (Div. 2) D. Arpa's weak amphitheater and Mehrdad's valuable Hoses —— DP(01背包)

    题目链接:http://codeforces.com/contest/742/problem/D D. Arpa's weak amphitheater and Mehrdad's valuable ...

  10. Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution —— 异或

    题目链接:http://codeforces.com/contest/742/problem/B B. Arpa's obvious problem and Mehrdad's terrible so ...

随机推荐

  1. Linux把查询结果写入到文本

    在Linux命令模式下,可以将查询结果写入文件.大概有两种方式,增量写入和覆盖写入. 增量写入: #iostat -m >> /tmp/iostat.txt 覆盖写入: #iostat - ...

  2. RS-485接口的防护电路设计

    RS-485总线标准是安防系统设备上应用最为广泛的物理层协议之一.RS-485的主要特点:支持远距离传输,长达4000英尺:双向信号差分传输,提高信号的噪音抑制能力,并且允许一条总线上可以挂接多个发射 ...

  3. SAM4E单片机之旅——10、UART与MCK之PLL

    为使用更更高的波特率,则需要更更高的外设时钟的频率.这个时候就需要用到锁相环(PLL)了.锁相环可以对输入的时钟进行分频.升频后进行输出.MCK可以使用的锁相环为PLLA,而PLLA的输入时钟为MAI ...

  4. ffmpeg ffplay播放延时大问题:播放延时参数设置

    使用ffplay播放视频源时,rtsp/rtmp等,会有一定的延时,这里我们可以通过设置ffplay播放参数将延时控制到最小. ffplay.exe -i rtmp://xxxxxxx -fflags ...

  5. json Gson

    package com.example.volleylearn; import java.util.ArrayList; import java.util.List; import java.util ...

  6. 关于<context:annotation-config/>配置

    对于spring项目的一些配置,一直感到有些混乱,今天看到一前辈总结的特别好,把自己的理解贴在这里,有不当的地方,后续继续学习: 当我们使用@Autowired.@Required等这些注解时,就要在 ...

  7. "未预编译文件 因此不能请求该文件"问题处理

    手里一个项目重新编译后发布,访问时提示未预编译文件“default.aspx”, 因此不能请求该文件.综合网上的解决方法,做了如下操作: 1.重新安装了AJAX Extension: 2.项目添加引用 ...

  8. 存储过程系列三:根据表别名方式distinct去重插入

    1.根据表别名方式distinct去重插入 insert into GG_XKZ_YLQXSCXKESL_SCDZ           ( bzj, xkzid,  sqid, jtdz, szsf, ...

  9. the art of seo(chapter five)

    Keyword Research ***The Theory Behind Keyword Research***1.When users go to search engines and type ...

  10. 【转载】rageagainstthecage.c源码以及注释

    如下: //头文件包含 #include <stdio.h> #include <sys/types.h> #include <sys/time.h> #inclu ...