【题目链接】:http://codeforces.com/problemset/problem/411/B

【题意】



处理器有n个核;然后有k个存储单元;

有m轮工作;每轮工作都会给每个核确定一个数字;

这个数字是这个核这轮工作会填的储存单元的编号x(1< x< k)

一轮工作可能有多个核去填同一个存储单元;

这种情况出现时,我们规定填这个存储单元的所有的核都被锁定;

同时这个存储单元也被锁定;

下次如果还有核去填这个存储单元的话,不论有没有多个核去填它,它都会被锁定;

(核被锁定之后忽略后面的操作);

要求你输出最后每个核被锁定与否;

【题解】



一轮一轮地模拟就好;

每次填一个存储单元之后;

就在那个存储单元里面(vector)push_back这个核;

每轮扫一遍所有存储单元;

对那些已经被锁定的存储单元以及核的个数超过1个的存储单元进行锁核的操作就好;

存储单元别忘了锁;



【Number Of WA】



0



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0),cin.tie(0) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 110; int n,m,k,a[N][N];
int core[N],cell[N];
vector <int> tcell[N]; int main(){
//Open();
Close();
cin >> n >> m >> k;
rep1(i,1,n){
rep1(j,1,m){
cin >> a[i][j];
}
}
rep1(j,1,m){
rep1(i,1,k) tcell[i].clear();
rep1(i,1,n){
if (core[i]) continue;
tcell[a[i][j]].pb(i);
}
rep1(i,1,k){
if ( (int) tcell[i].size() > 1 || cell[i]){
rep1(l,0,(int) tcell[i].size()-1){
core[tcell[i][l]] = j;
}
if (!cell[i]) cell[i] = j;
}
}
}
rep1(i,1,n)
cout << core[i] << endl;
return 0;
}

【codeforces 411B】Multi-core Processor的更多相关文章

  1. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  2. 【Spring开发】—— Spring Core

    原文:[Spring开发]-- Spring Core 前言 最近由于一些工作的需要,还有自己知识的匮乏再次翻开spring.正好整理了一下相关的知识,弥补了之前对spring的一些错误认知.这一次学 ...

  3. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  4. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  5. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

  6. 【codeforces 709B】Checkpoints

    [题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...

  7. 【codeforces 709C】Letters Cyclic Shift

    [题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...

  8. 【Codeforces 429D】 Tricky Function

    [题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...

  9. 【Codeforces 670C】 Cinema

    [题目链接] http://codeforces.com/contest/670/problem/C [算法] 离散化 [代码] #include<bits/stdc++.h> using ...

随机推荐

  1. 05 ADO.net

    ADO.NET就是一组类库 操作数据库用的.

  2. elementUI 上传.csv文件不成功 导入功能

    前言:element上传excel文件   导入功能 目标:点击导入,将excel表格的数据填充到表格. <el-upload class="upload-demo" :ac ...

  3. 😈 HTTP 学习笔记

  4. 洛谷 P1338 末日的传说 (字典序 + 逆序对)

    这道题需要对排列有深刻的理解和认识 给出逆序对的个数,求改逆序对个数的字典序最小的排列 那么既然是最小,那么一开始一段肯定是升序,一直到某个数后才开始改变 即1 2 3-- n-1 n a b c d ...

  5. promise的原理

    promise的原理 一旦状态改变,就不会再变,任何时候都可以得到这个结果.Promise 对象的状态改变,只有两种可能:从 pending 变为 fulfilled 和从 pending 变为 re ...

  6. Javascript 实现锚点(Anchor)间平滑跳转

    (function($){ $.fn.scroller = function(options){ var defaultVal = { duration: }; var obj = $.extend( ...

  7. [ReactVR] Animate Text, Images, Views, and 3D Elements Using the Animated Library in React VR

    Motion is an important aspect of a complete immersive experience, therefor we are going to look into ...

  8. Genymotion出现Installation error: INSTALL_FAILED_CPU_ABI_INCOMPATIBLE错误解决方法

    今天在Genymotion上执行曾经的一个项目(libs中有多个SDK和so文件)时,出现下面错误: Console控制台中:Installation error: INSTALL_FAILED_CP ...

  9. ionic2集成极光推送

    ionic2集成极光推送: ionic2api:https://ionicframework.com/docs/ 极光推送官网:https://www.jiguang.cn android-怎么注册极 ...

  10. 27.boost多线程

    #define _CRT_SECURE_NO_WARNINGS #include <boost/thread.hpp> #include <iostream> #include ...