本文整理汇总了C++中vii::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ vii::clear方法的具体用法?C++ vii::clear怎么用?C++ vii::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vii
的用法示例。
在下文中一共展示了vii::clear方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
ios::sync_with_stdio(0);
double d;
int m, tc = 1;
while( cin >> d >> m) {
cout << "Case " << tc++ << ":" << endl;
memo.clear(); memo.resize(105, -1);
prices.clear(); prices.resize(m + 1);
prices[0].first = 1; prices[0].second = (d + eps) * 100;
for(int i = 1; i <= m; i++) {
int tmp; cin >> tmp >> d;
prices[i].first = tmp; prices[i].second = (d + eps) * 100;
}
string str;
cin.get();
getline(cin, str);
stringstream ss(str);
int tmp;
while(ss >> tmp) {
cout << "Buy " << tmp << " for $" << fixed << setprecision(2) << (double)solve(tmp) / 100 << endl;
}
}
return 0;
}
示例2: main
int main(){
FASTER;
int n;
int Case=1;
while(cin >> n, n){
cas.clear();
for(int i = 0 ; i < n ; i++){
int a,m,g;
cin >> a >> m >> g;
castle c{a,m,g};
C.push_back(c);
cas.push_back(ii(max(a,m+g), m+g));
}
adj.assign(n,vi());
for(int i = 0 ; i < n-1;i++){
int u,v;cin >> u >> v;
u--,v--;
adj[u].push_back(v);
adj[v].push_back(u);
}
ii ans = ii(1e9,1e9);
for(int i = 0 ; i < 1;i++){
ans = min(ans,dfs(i));
}
cout << "Case " << (Case++)<< ": ";
cout << ans.first << endl;
}
}
示例3: main
int main(){
FILE *f;
f =fopen("input/OrderingTasks.in", "r");
#ifdef ONLINE_JUDGE
f = stdin;
#endif
int m,n;
while(fscanf(f, "%d %d", &n, &m) == 2 && n){
g.clear();
g.assign(n, vi());
for(int i = 0 ; i < m ; i++){
int u,v;
fscanf(f, "%d %d", &u,&v);
g[u-1].push_back(v-1);
}
vi sortedV;
for(int i = 0 ; i < n ; i++){
if(!visited[i])
dfs(i, sortedV);
}
memset(visited, 0, sizeof visited);
for(int i = sortedV.size() -1 ; i >= 0 ; i--){
printf("%d", sortedV[i] + 1);
if(i)printf(" ");
else printf("\n");
}
}
return 0;
}
示例4: ok
bool ok(int l){
int c1 = 0;
int c2 = 0;
for (int i = 1; i <= l; ++i) {
if(a[i] < a[c1])c1 = i;
if(b[i] < b[c2])c2 = i;
}
vector<pair<ll, ii> > p;
for (int i = 0; i < m; ++i) {
if(tp[i]==1) p.push_back(pair<ll, ii> (a[c1]*c[i], ii(i,c1)));
if(tp[i]==2) p.push_back(pair<ll, ii> (b[c2]*c[i], ii(i,c2)));
}
sort(p.begin(), p.end());
int sum = 0;
int cnt = 0;
X.clear();
for (int i = 0; i < p.size(); ++i) {
if(sum+p[i].first>s)break;
sum+=p[i].first;
X.push_back(p[i].second);
cnt++;
}
return cnt >= k;
}
示例5: main
int main(){
int t,m,u,v,w;
scanf("%d",&t);
while(t--){
sum=1;
edges.clear();
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
pSet[i]=i;
}
for (int i = 0; i < m; ++i)
{
scanf("%d%d%d",&u,&v,&w);
edges.push_back(make_pair(u, make_pair(v,w)));
}
sort(edges.begin(),edges.end(),compare);
for (vector< pair<int,ii> >::iterator i = edges.begin(); i != edges.end(); ++i)
{
// printf("%d %d %d\n", i->first,i->second.first,i->second.second);
if(!isSameSet(i->first,i->second.first)){
sum*=(i->second.second);
if(sum>mod)
sum=sum%mod;
unionSet(i->first,i->second.first);
}
}
printf("%lld\n",sum%mod);
}
return 0;
}
示例6: main
int main()
{
int test;
scanf("%d", &test);
for(int te=1;te<=test;te++)
{
grip.clear();
data.clear();
scanf("%d %d", &n, &m);
for(int i=0;i<n;i++)
{
string x;
cin>>x;
grip.push_back(x);
}
getGraph();
sol(piii(pii(data[0].first, data[0].second),0));
int pos=-1;
for(int i=0;i<4;i++)
if(d[data[1].first][data[1].second][i] !=-1)
{
pos=i;
break;
}
if(pos>=0)
printf("Case #%d: %d\n", te,d[data[1].first][data[1].second][pos]);
else
printf("Case #%d: impossible\n", te);
}
}
示例7: main
int main(){
int vertices,arestas,caso=1;
while(scanf("%d %d", &vertices, &arestas) && vertices && arestas){
for(int i = 0; i < arestas; i++)
{
int u,v;
scanf("%d %d", &u, &v);
adj[u].push_back(v);
adj[v].push_back(u);
}
memset(dfs_num, -1 , sizeof(dfs_num));
memset(visitados, 0 , sizeof(visitados));
dfsNumbercounter = 0;
for(int i = 0; i <= vertices; i++){
if(dfs_num[i]==DFS_WHITE){findBridges(i);}
}
cout << caso++ << endl;
cout << endl;
for(int i = 0; i < bridge.size();i++){
printf("%d %d\n",bridge[i].first,bridge[i].second);
}
cout << "#" << endl;
bridge.clear();
int i=vertices+5;
while(i--){
adj[i].clear();
}
}
return 0;
}
示例8: reset
void reset()
{
id = 0;
ans.clear();
rep(i,n)
{
adj[i].clear();
check[i] = false;
low[i] = ind[i] = cnt[i] = 0;
parent[i] = i;
}
示例9: main
int main(){
FASTER;
int T;
cin >> T;
while(T--){
cin >> N >> k;
blue.clear();red.clear();
for (int i = 0; i < N; ++i) {
int x,y;
string color;
cin >> x >> y >> color;
(color == "blue" ? blue : red).push_back(ii(x,y));
}
int lo = 0, hi = INF,mid, ans = -1;
int kSq = k*k;
while(lo < hi){
int mid = (lo + hi) / 2;
createEdges(mid);
int fences = maxFlow();
if(fences >= k){
hi = mid;
ans = mid;
}else{
lo = mid + 1;
}
}
if(ans == -1)
cout << "Impossible" << endl;
else
cout << (int)(sqrt(ans) + 1) << endl;
}
return 0;
}
示例10: main
int main(){
int t, n, i,j, x,y;
scanf("%d", &t);
while(t--){
scanf("%d", &n);
ps.clear();
for(i=0; i<n; i++){ scanf("%d", &x); ps.push_back(ii(x,-1)); }
for(i=0; i<n; i++){ scanf("%d", &x); ps[i].second=x; }
sort(ps.begin(), ps.end());
ys.clear();
for(i=0; i<n; i++) ys.push_back(ps[i].second);
printf("%d\n", LIS_Len(ys));
}
return 0;
}
示例11: main
int main(){
//maketestcase();
//freopen("input.txt", "r", stdin);
int n;
while(scanf("%d", &n) != EOF){
v.clear();
for(int i = 0; i < n; i++){
al[i].clear();
visited[i] = false;
}
for(int i = 0; i < n; i++){
int x, y;
scanf("%d %d", &x, &y);
v.pb(mkp(x,y));
}
map<ii, vi> m;
for(int i = 0; i < n; i++){
int x = v[i].first;
int y = v[i].second;
m[mkp(x/5, y/5)].pb(i);
}
int ix[5] = {0, 1, 1, 1, 0};
int iy[5] = {1, 1, 0, -1, -1};
repSTL(m, iter){
generateGraph(iter->second,iter->second);
ii p = iter->first;
for(int i = 0; i < 5; i++){
int x = p.first + ix[i];
int y = p.second + iy[i];
typeof(m.begin()) iter2 = m.find(mkp(x,y));
if(iter2 != m.end()){
generateGraph(iter->second, iter2->second);
}
}
}
m.clear();
int minS = 0;
for(int i = 0; i < n; i++){
if(!visited[i]){
ii p = bipartite(i);
minS += min(p.first, p.second);
}
}
printf("%d\n", minS);
}
示例12: printPath
vii printPath(ii u, ii s) {
path.clear();
print(u, s);
return path;
}