您当前的位置: 首页 > 

钟钟终

暂无认证

  • 4浏览

    0关注

    232博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

3/20 思维+双指针

钟钟终 发布时间:2022-03-30 21:36:44 ,浏览量:4

思维

http://oj.ecustacm.cn/problem.php?id=1373 尺取法+贪心 一种我很少去想的思维方式,很巧秒。采用双指针,每有一个帖子进来就统计(i负责遍历);当时间超过限定时,当前帖子失效就得减一。若超过k,把他放到set集合里(set默认排序,去重,方便)

#include 
using namespace std;
const int N=5e5+5;
const int inf=0x3f3f3f3f;
int n,k,d,num[N];
sets;
struct node
{
    int ts,id;
}e[N];
bool cmp(node e1,node e2)
{
    return e1.ts>n>>d>>k;
    for(int i=1;i>e[i].ts>>e[i].id;
    sort(e+1,e+n+1,cmp);
    for(int i=1,j=1;i=d)
        {
            num[e[j].id]--;j++;
        }
        if(num[id]>=k)
            s.insert(id);
    }
    set::iterator it;
	for(it=s.begin();it!=s.end();it++)  //使用迭代器进行遍历
	{
		printf("%d\n",*it);
	}
	return 0;
}

深搜+连通块 http://oj.ecustacm.cn/problem.php?id=1365 如果联通块的数目等于靠海的数目,则会被淹没

#include 
using namespace std;
const int N=1e3+5;
const int inf=0x3f3f3f3f;
char mp[N][N];
int n,ans;
int dx[5]={0,1,0,-1};
int dy[5]={1,0,-1,0};
bool vis[N][N];
void dfs(int x,int y,int &num,int &cnt)
{
    vis[x][y]=1;num++;
    if(x-1>=1&&mp[x-1][y]=='.') cnt++;
    else if(x+1=1&&mp[x][y-1]=='.') cnt++;
    else if(y+1n;
    for(int i=1;imp[i][j];
    for(int i=1;i=1;i--)
        {
            if(r==n||c==m||(row[a[i]]&&col[b[i]]))
                continue;
            if(!row[a[i]])
            {
                row[a[i]]=1;r++;
            }
            if(!col[b[i]])
            {
                col[b[i]]=1;c++;
            }
            ans=ans*k%mod;
        }
        cout            
关注
打赏
1664378814
查看更多评论
0.0463s