USACO section 2.1 Sorting a Three-Valued Sequence

PHP版本对接支付宝支付接口 电脑网站 详细介绍 沙箱环境 超简单易懂 PHP版本对接支付宝支付接口 其实理顺了思路后,按照我接下来的步骤来,真的超级简单啊,为啥有那么多的朋友们折腾了那么久呢,嘿嘿,跟我走吧~ 我是昨天晚上洗完澡之后,大概八九点,才开始正式开工尝试去这一工程的,我去支付宝的蚂蚁金服开放平台里把各个知识点和文档大概都看了一遍,大致弄明白了要怎么操作了,建议大家看看电脑网站开发文档,忙到了夜里十二点左右,成功地用支付宝给的Demo完成了付款操... 阅读详情
Sorting a Three-Valued Sequence
IOI'96 - Day 2

Sorting is one of the most frequently performed computational tasks. Consider the special sorting problem in which the records to be sorted have at most three different key values. This happens for instance when we sort medalists of a competition according to medal value, that is, gold medalists come first, followed by silver, and bronze medalists come last.

In this task the possible key values are the integers 1, 2 and 3. The required sorting order is non-decreasing. However, sorting has to be accomplished by a sequence of exchange operations. An exchange operation, defined by two position numbers p and q, exchanges the elements in positions p and q.

You are given a sequence of key values. Write a program that computes the minimal number of exchange operations that are necessary to make the sequence sorted.

PROGRAM NAME: sort3

INPUT FORMAT

Line 1:N (1 <= N <= 1000), the number of records to be sorted
Lines 2-N+1:A single integer from the set {1, 2, 3}

SAMPLE INPUT (file sort3.in)

9
2
2
1
3
3
3
2
3
1

OUTPUT FORMAT

A single line containing the number of exchanges required

SAMPLE OUTPUT (file sort3.out)

4

 

这题A的很冤,整整交了四次,是目前为止交的次数最多的了

解题思路:因为只有1,2,3,所以只要记录s存1,2,3所出现的次数,把其分为1,2,3三个区间,然后遍历1的区间,找到非1 的数,然后遍历这个数的区间去找1

若没有,则把任意一个非此区间的数与之交换。当1区间均为1时,只要在遍历2 的区间找到非2 的数的个数于前面的交换次数相加即为答案

 

 

 

/*
ID:nealgav1
PROG:sort3
LANG:C++
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 1005
using namespace std;
int f[N];
int s[4];
void swapp(int&a,int &b)
{int z;
  z=a;a=b;b=z;
}
int qqsort(int n)
{
  int l=0,mid=s[1]+1,r=s[1]+s[2]+1;
  int i,j,ans=0;
  while(1)
  {
    for(i=l+1;i<=s[1];i++)
    {
      if(f[i]!=1)break;l++;
    }
    if(l==s[1])break;
    if(f[i]==2)
     { bool flag=0,ff=1;
      for(j=mid;j<=s[1]+s[2];j++)
      {
        if(f[j]!=2&&ff)mid=j,ff=0;
        if(f[j]==1){swapp(f[j],f[i]),ans++;flag=1;break;}
      }
        if(!flag)
        for(j=mid;j<=s[1]+s[2];j++)
        if(f[j]==3){swapp(f[j],f[i]),ans++;break;}
     }
    else
    {
      bool sss=0,ss=1;
      for(j=r;j<=n;j++)
      {if(f[j]!=3&&ss)
         { r=j;ss=0;}
        if(f[j]==1)
         {swapp(f[j],f[i]),ans++;sss=1;break;}
      }
      if(!sss)
      for(j=r;j<=n;j++)
      if(f[j]==2){swapp(f[j],f[i]);ans++;break;}
    }
  }
  for(i=s[1]+1;i<=s[2]+s[1];i++)
  if(f[i]==3)ans++;
  return ans;
}
int main()
{
  int n;
  freopen("sort3.in","r",stdin);
  freopen("sort3.out","w",stdout);
  scanf("%d",&n);
  s[1]=s[2]=s[3]=0;
  for(int i=1;i<=n;i++)
  {
    scanf("%d",&f[i]);s[f[i]]++;
  }
   printf("%d\n",qqsort(n));
}


 

 

 

 

Sorting A Three-Valued Sequence
Russ Cox

We read the input into an array, and sort a copy of it in another array, so we know what we have and what we want.

A swap touches two elements, so it can correct at most two misplaced elements. We run through the array looking for pairs of misplaced elements that a swap would correct, and do those swaps.

The remaining misplaced elements form little cycles: a 1 where a 2 should be, a 2 where a 3 should be, and that 3 where the 1 should be. It takes two swaps to correct such a cycle. So we count the number of such cycles (by counting misplaced elements and dividing by three) and then add in two times that many swaps.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

#define MAXN 	1000

int n;
int have[MAXN];
int want[MAXN];

int
intcmp(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

void
main(void)
{
    int i, j, k, n, nn[4], nswap, nbad;
    FILE *fin, *fout;

    fin = fopen("sort3.in", "r");
    fout = fopen("sort3.out", "w");
    assert(fin != NULL && fout != NULL);

    fscanf(fin, "%d", &n);

    for(i=0; i<n; i++) {
	fscanf(fin, "%d", &have[i]);
	want[i] = have[i];
    }
    qsort(want, n, sizeof(want[0]), intcmp);

    /* swaps that correct two elements */
    nswap = 0;
    for(i=0; i<n; i++)
    for(j=0; j<n; j++) {
	if(have[i] != want[i] && have[j] != want[j]
	        && have[i] == want[j] && have[j] == want[i]) {
	    have[i] = want[i];
	    have[j] = want[j];
	    nswap++;
	}
    }

    /* remainder are pairs of swaps that correct three elements */
    nbad = 0;
    for(i=0; i<n; i++)
	if(have[i] != want[i])
	    nbad++;

    assert(nbad%3 == 0);
    nswap += nbad/3 * 2;

    fprintf(fout, "%d\n", nswap);
    exit(0);
}

Dan Jasper from Germany writes:

The previous solution needs a copy of the original list and O(N2) time. I think it was necessary with the original task, where you had to print out the exchange operations, but to just count them, there is a more efficient solution. You can count the "1", "2" and "3", so you can calculate in what parts (buckets) of the list they have to be. The rest of the solution is somehow equal to yours, but all in all it uses O(N) time and does not need a copy of the list.

#include <stdio.h>

int list[1000], N, res, count[3], start[3];
in[3][3]; // this counts the number of "1"s in bucket "2", ...

void readFile() {
    FILE *f; int i;
    f = fopen("sort3.in", "r");
    fscanf(f, "%d", &N);
    for(i = 0; i < N; i++) {
        fscanf(f, "%d", &list[i]);
    }
    fclose(f);
}

void writeFile() {
    FILE *f;
    f = fopen("sort3.out", "w");
    fprintf(f, "%d\n", res);
    fclose(f);
}

void findBuckets() {
    int i;
    for(i = 0; i < N; i++) count[list[i]-1]++;
    start[0] = 0;
    start[1] = count[0];
    start[2] = count[0] + count[1];
}

void findWhere() {
    int i, j;
    for(i = 0; i < 3; i++) {
        for(j = 0; j < count[i]; j++) in[list[start[i] + j]-1][i]++;
    }
   }

void sort() {
    int h;
    // 1 <-> 2
    h = in[0][1];
    if(in[1][0] < h) h = in[1][0];
    res += h; in[0][1] -= h; in[1][0] -= h;
    // 3 <-> 2
    h = in[2][1];
    if(in[1][2] < h) h = in[1][2];
    res += h; in[2][1] -= h; in[1][2] -= h;
    // 1 <-> 3
    h = in[0][2];
    if(in[2][0] < h) h = in[2][0];
    res += h; in[0][2] -= h; in[2][0] -= h;

    // Cycles
    res += (in[0][1] + in[0][2]) * 2;
}

void process() {
    findBuckets();
    findWhere();
    sort();
}

int main () {
    readFile();
    process();
    writeFile();
    return 0;
}

Bulgaria's Evgeni Dzhelyov writes:

I read the elements one by one and count them, so we know exactly how 1s, 2s and 3s we have and we know how the sorted array looks like. Then I count the 2s in 1 and 1s in 2, so it is obvious that we need min(2sin1, 1sin2) swaps, I do the same for 1-3 and 2-3. The sum of all these mins give us the number of direct swaps we need. After that number of swaps we would have N 1s, 2s and 3s and we would need 2*N swaps, where N is max(2sin1, 1sin2) - min(2sin1, 1sin2).

Here is the source code:

#include <fstream>

using namespace std;

int min (int a, int b) { return a < b ? a : b; }
int max (int a, int b) { return a > b ? a : b; }

int main () {
    int s[1024];
    int n;
    int sc[4] = {0};
    
    ifstream fin("sort3.in");
    ofstream fout("sort3.out");
    fin>>n;
    for (int i = 0; i < n; i++) {
        fin>>s[i];
        sc[s[i]]++;
    }
    int s12 = 0, s13 = 0, s21 = 0, s31 = 0, s23 = 0, s32 = 0;
    for (int i = 0; i < sc[1]; i++){
        if (s[i] == 2) s12++;
        if (s[i] == 3) s13++;
    }
    
    for (int i = sc[1]; i < sc[1]+sc[2]; i++){
        if (s[i] == 1) s21++;
        if (s[i] == 3) s23++;
    }
    
    for (int i = sc[1]+sc[2]; i < sc[1]+sc[2]+sc[3]; i++){
        if (s[i] == 1) s31++;
        if (s[i] == 2) s32++;
    }
    
    fout<<min(s12, s21)+min(s13, s31)+min(s23, s32) +
					2*(max(s12, s21) - min(s12, s21))<<endl;
    return 0;
}


 

 

USER: Neal Gavin Gavin [nealgav1]
TASK: sort3
LANG: C++

Compiling...
Compile: OK

Executing...
   Test 1: TEST OK [0.000 secs, 3348 KB]
   Test 2: TEST OK [0.000 secs, 3348 KB]
   Test 3: TEST OK [0.000 secs, 3348 KB]
   Test 4: TEST OK [0.011 secs, 3348 KB]
   Test 5: TEST OK [0.000 secs, 3348 KB]
   Test 6: TEST OK [0.000 secs, 3348 KB]
   Test 7: TEST OK [0.000 secs, 3348 KB]
   Test 8: TEST OK [0.000 secs, 3348 KB]

All tests OK.

Your program ('sort3') produced all correct answers! This is your submission #5 for this problem. Congratulations!

Here are the test data inputs:

------- test 1 ----
3
2
1
3
------- test 2 ----
2
1
1
------- test 3 ----
6
1
2
3
2
3
1
------- test 4 ----
9
2
2
1
3
3
3
2
3
1
------- test 5 ----
20
1
1
3
2
1
1
1
3
2
1
3
3
2
1
3
1
1
2
3
1
------- test 6 ----
50
1
1
1
3
1
3
2
1
2
3
3
1
3
2
1
1
2
3
2
2
3
3
2
3
2
2
3
1
1
1
1
1
1
1
3
1
1
2
2
3
1
1
3
3
2
1
1
1
3
2
------- test 7 ----
100
3
2
2
3
1
2
2
2
1
2
2
3
2
3
2
2
3
3
2
2
2
3
3
3
3
2
2
1
2
2
1
1
1
3
1
1
2
2
3
3
1
1
2
2
1
1
3
1
3
1
3
2
1
2
1
3
3
3
1
2
1
1
2
1
3
2
2
1
1
1
3
1
2
2
3
3
2
3
3
2
1
2
3
1
3
1
1
3
3
1
1
1
1
3
1
1
2
3
1
2
------- test 8 ----
1000
3
1
3
2
1
1
3
3
2
1
3
2
3
2
3
2
3
2
1
1
3
3
3
2
1
1
2
3
2
2
1
1
3
1
3
1
1
2
3
3
3
3
2
3
2
1
2
1
3
2
1
2
2
1
1
3
1
3
3
3
1
1
1
1
1
3
2
1
2
2
3
2
1
2
1
3
2
3
3
2
2
1
1
3
1
1
3
2
3
2
2
1
3
2
2
3
1
3
1
2
1
1
1
2
2
1
2
1
3
1
2
1
1
2
1
2
3
1
1
3
2
2
1
2
1
2
1
1
2
2
3
3
2
3
2
1
1
3
1
1
3
3
2
1
2
2
3
1
2
3
3
1
2
3
2
2
2
3
3
3
1
3
2
3
3
3
3
1
2
1
1
2
3
2
2
1
1
2
2
3
2
2
3
3
2
2
2
3
1
2
3
2
2
1
1
1
1
3
2
3
1
2
1
3
1
3
1
1
1
2
3
3
3
3
2
1
2
1
1
2
3
3
3
1
1
1
2
2
1
3
1
1
2
2
3
2
2
1
3
3
2
3
2
2
3
1
3
1
1
3
3
3
3
2
1
1
3
2
2
3
2
2
3
3
1
3
1
2
3
3
1
2
3
2
3
2
2
2
2
3
2
1
3
1
3
3
1
2
2
3
1
3
2
1
2
2
3
3
3
3
3
1
1
2
3
3
3
2
2
2
1
3
2
1
1
1
1
2
3
2
1
1
2
2
1
1
3
1
3
3
3
3
3
3
1
3
3
1
1
1
2
1
1
3
1
1
1
1
3
3
3
3
3
1
2
1
1
1
1
1
1
3
3
1
3
1
3
2
2
3
3
3
1
3
3
1
1
1
2
3
1
2
3
3
3
1
1
3
2
1
1
2
1
1
2
3
2
2
2
3
1
2
3
1
2
3
2
2
3
1
1
3
2
1
3
1
1
3
1
2
1
2
3
1
2
2
1
1
3
2
3
1
1
3
1
2
2
3
3
2
3
1
1
2
1
1
3
2
3
3
3
3
2
3
1
1
1
1
1
1
3
1
1
3
3
2
1
1
2
1
2
1
2
3
3
3
3
2
1
3
2
3
3
3
2
3
3
3
1
3
1
3
3
1
2
2
3
3
3
1
1
2
2
3
1
1
2
1
2
2
3
3
2
3
3
1
2
2
3
3
2
3
2
1
1
1
3
1
1
3
1
1
1
2
3
1
3
2
2
2
1
1
1
2
1
1
3
3
2
2
2
3
2
3
1
3
3
1
3
1
3
1
1
1
3
1
2
2
3
3
3
3
1
1
1
1
1
3
3
3
2
1
3
1
3
3
1
3
1
3
3
1
1
1
1
3
2
2
2
1
2
1
3
2
2
1
2
2
1
1
2
3
2
1
3
2
1
3
2
1
3
2
1
3
2
2
2
1
3
3
1
1
1
1
3
3
1
1
2
1
2
3
1
1
3
3
2
3
3
3
1
3
1
1
2
3
3
1
3
2
1
3
3
2
3
2
1
1
3
2
2
2
1
2
2
1
2
3
3
1
3
1
3
1
2
2
3
1
3
2
3
3
2
3
2
2
2
2
2
1
3
1
2
1
2
1
1
3
1
1
1
3
1
1
3
3
2
3
3
2
2
2
1
1
1
2
2
2
1
1
3
1
1
2
2
3
2
3
2
2
3
3
2
1
3
2
3
2
1
3
3
2
1
1
2
2
3
1
1
3
2
3
1
2
1
2
1
3
1
3
2
1
2
3
2
1
2
1
3
2
1
2
1
1
2
3
3
1
1
3
1
2
2
1
3
3
2
1
2
2
1
1
3
2
3
1
3
1
2
2
3
2
3
1
2
2
1
2
2
1
1
2
2
3
2
2
2
1
3
1
3
3
1
2
2
1
2
1
1
3
3
1
1
2
1
3
1
1
1
2
2
2
1
3
1
2
2
2
3
1
2
2
1
3
3
2
3
2
2
1
2
1
1
2
3
2
2
3
3
3
2
1
1
2
1
1
1
3
3
3
1
2
1
1
1
1
2
1
3
1
1
1
2
2
3
1
1
1
1
3
1
2
1
1
3
2
2
1
1
2
3
1
3
1
1
1
2
3
1
1
3
2
1
1
3
3
2
3
1
3
3
1
1
1
2
1
2
1
1
3
3
1
3
2
2
1
3
1
1
3
1
1
1
2
2
1
2
3
3
3
2
3
1
3
3
3
1
1
1
2
1
3
3
3
1
1
1
1
2
2
1
2
2
2
1
3
2
3
3
2

人大金仓的‘影子表’sys_user:搞懂Schema优先级,告别字段不存在的报错 本文深入解析人大金仓数据库中‘影子表’sys_user的Schema优先级问题,帮助开发者解决字段不存在的报错。通过分析Schema搜索路径机制,提供四种解决方案,包括连接时指定Schema、动态调整搜索路径、永久修改用户设置和使用完全限定表名,确保查询准确无误。 阅读详情

相关推荐

基于AIS动态数据与AI结合得经纬度标示算法

港口船舶智能标注系统 本系统通过结合摄像头视频流和AIS船舶动态数据,利用AI技术实现船舶实时标注功能。系统架构包括视频流处理、AIS数据解析、船舶检测匹配和坐标映射转换等模块。关键技术步骤: AIS数据获取:通过本地接收机或网络API获取船舶位置、航速等信息 AI目标检测:采用YOLOv8等模型识别视频中的船舶 船舶匹配算法:通过位置投影或运动轨迹匹配视频目标与AIS数据 坐标映射:使用相机标定技术将经纬度转换为图像坐标 实时标注:在视频画面上叠加船名、位置等关键信息 应用场景包括港口监控、智能海事管理和

qianbo042311的博客 1836

USACO 2.1 Sorting a Three-Valued Sequence

题目: Sorting is one of the most frequently performed computational tasks. Consider the special sorting problem in which the records to be sorted have at most threedifferent key values. This happens

Aaron的博客 431

关于Vscode配置Unity环境时的一些报错问题(持续更新)

3.找到设置文件,添加如下代码,用于告诉VSCode)在处理 C# 项目时优先使用 C# 扩展来加载和管理项目,而不是使用 C# Dev Kit 或其他扩展。1.很可能是unity的插件版本问题,打开window > package manager将。2.很可能是项目文件的问题,建议unity打开edit > perfercenes。3.手动重装其他版本的.Net框架(去官网找,多下几个无所谓的)解决:(由于造成问题不一样,所以建议都尝试一次)下载net请求超时(一般都会超时很正常的)

bug制造机 1903

【USACO 2.1】Sorting A Three-Valued Sequence

/* TASK: sort3 LANG: C++ URL: http://train.usaco.org/usacoprob2?a=RkPIMxsFWzm&S=sort3 SOLVE: n个数的序列,值只有1、2、3,通过几次互换可以变成升序。 num[i][j]为排完序后为数字i,原来是数字j的位置的个数, 所有i!=j的min(num[i][j],num[j]...

dingguayi7025的博客 151

VirtualBox虚拟机拖放文件总失败?手把手教你配置双向拖放与共享文件夹(Ubuntu版)

本文详细指导如何在VirtualBox的Ubuntu虚拟机中配置高效的数据交换方案。核心是安装VirtualBox Guest Additions,并在此基础上开启双向拖放与共享粘贴板功能,同时建立稳定的共享文件夹,彻底解决主机与虚拟机间文件传输失败的问题,构建无缝的跨系统工作环境。

weixin_29245767的博客 238

RocketMQ源码分析之消息轨迹

文章目录前言一、消息轨迹二、消息轨迹源码分析1、producer端2、consumer端三、消息轨迹中存储的信息1.TraceContext2.TraceBean3.TraceType四、总结 前言   本篇文章将会从以下方面介绍消息轨迹:什么是消息轨迹?如何启用消息轨迹?示例demo、消息轨迹的源码分析和消息轨迹中存储的信息。最后会用一张图来总结消息轨迹的工作原理。 一、消息轨迹 1.什么是消息轨迹? 消息轨迹是用来跟踪记录消息发送、消息消费的轨迹。 2.如何启用消息轨迹? broker端 需要在b

不爱学习的小妞博客 1081

USACO 2.1 Sorting A Three-Valued Sequence

Type: tricky 题目描述: Sorting a Three-Valued Sequence Sorting is one of the most frequently performed computational tasks. Consider the special sorting problem in which the records to be sorted ha...

weixin_34406061的博客 124

C3 模块与普通 Bottleneck 堆叠区别

维度普通 Bottleneck 堆叠C3 模块设计理念残差学习CSP + 特征分治信息路径单一路径双路径(主干 + bypass)融合方式相加(Add)拼接(Concat)+ 卷积计算效率较低高(通道减半)特征保留弱(多次非线性)强(直连保留原始信息)梯度传播单一主路径多样化、更稳定任务适配通用(分类为主)专为目标检测优化可扩展性有限极强(即插即用各种模块)实际性能基准线显著优于(尤其在小目标和效率方面)

浩瀚之水的专栏 114

[P1459 [USACO2.1]三值的排序 Sorting a Three-Valued Sequence]

P1459 [USACO2.1]三值的排序 Sorting a Three-Valued Sequence 解题思路:贪心。对b数组排序,先找如果交换一次就可以让两组都相等的交换一下,再找交换一次,可以使得其中一个相等的。 #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double lf; typedef unsigned long long ull; typedef pair&lt

多一些不为什么的坚持 476

Trae+雪球MCP,化身专业的股票分析师(玩转100个MCP系列第二弹)

大家好呀,我是程序员夏叶,深度AI编程使用者,专注于分享AI编程方面的使用技巧、经验以及前沿资讯,有兴趣的可以关注我的公众号,一起学习,共同进步。第二弹,使用Trae+雪球MCP,获取股票实时行情,分析股票走向等,写代码间隙看看股票价格,研究研究行情,哈哈。真的很不错呀,最关键的是,足够隐蔽,同事以为你在写代码,实际你在浏览股票行情,哈哈,感兴趣的可以试一下哦。说实话,沧州明珠这只股我算是砸手里了,不过还好买的不多,哈哈。

cpp加油站的专栏 525

​非线性分析-增加位移量可能出现下面错误。虽然求解无法在所有时间点完成,但在某些点上仍能够求解部分结果。请参阅“帮助系统”中的故障排除,以了解更多信息详情。由于受约束,规划求解引擎无法收敛

基于收敛状态拆分载荷步‌:在已收敛的载荷步基础上,将未收敛的关键区域拆分为更细的子步,比如在载荷突变点前设置5~10个子步,逐步加载。替换冲突约束为弱约束‌:若存在约束冲突,将刚性约束替换为弱弹簧约束(刚度设为1e-6~1e-4),既限制刚体位移,又不影响结构的变形自由度,命令流:SPRING, NODE, K, 1e-6。部分区域约束完整,但存在未被约束的刚体自由度,或约束类型与大变形/接触逻辑冲突,比如某部件的位移约束在初始阶段有效,但大变形后约束位置脱离实际受力点,导致求解器在该阶段无法收敛。

qq_15963745的博客 188

USACO Section 2.1 Sorting A Three-Valued Sequence Sorting a Three-Valued Sequence(策略题)

Sorting a Three-Valued SequenceIOI'96 - Day 2 Sorting is one of the most frequently performed computational tasks. Consider the special sorting problem in which the records to be sorted have at...

angtongyou1893的博客 129

【23】C++实战篇——C++报错:LNK2001:无法解析的外部符号 ,LNK2019: 无法解析的外部符号,原因分析及解决方法

该文分析了VS项目中出现的"无法解析的外部符号"LNK2001/LNK2019错误。问题表现为跨项目共享变量时,Projector项目无法解析Line项目中声明的外部变量ImgSavePath和ImgFormat。原因在于头文件声明了变量但未包含实现的源文件。解决方法是将getLine.cpp文件添加到Projector项目中。文章还总结了两种错误代码的区别:LNK2001通常对应变量缺失,LNK2019对应函数缺失。最后列出了具体的报错信息,包括无法解析的变量和函数符号。

程序员,他们想的是什么?他们想的永远都是技术,他们崇尚的也永远都是技术。 2025

USACO-Section 2.1 Sorting a Three-Valued Sequence (贪心)

1.3第一个TEXT说过是贪心解法,幸亏还记得住。 官方题解: Algorithm The sequence has three parts: the part which will be 1 when in sorted order, 2 when in sorted order, and 3 when in sorted order. The greedy algorithm swaps as many as possible of the 1's in the 2 part with 2's in t

idealism_xxm的专栏 688

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

USACO Section2.1 Sorting a Three-Valued Sequence

Sorting a Three-Valued Sequence IOI'96 - Day 2 Sorting is one of the most frequently performed computational tasks.Consider the special sorting problem in which the records to be sortedhave at

239

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

USACO Section 2.1 Sorting a Three-Valued Sequence

/* ID: lucien23 PROG: sort3 LANG: C++ */ #include #include #include #include using namespace std; void exchange(int nums[], int begin, int end, int N, int x); int sum = 0; int main() { ifstream

程序缘 1074

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

USACO Training Section 2.1 Sorting a Three-Valued Sequence

[url="http://ace.delos.com/usacoprob2?a=1037lYCaha0&S=sort3"]英文原题[/url] [url="http://www.wzoi.org/usaco/12%5C510.asp"]中文题译[/url] 题目大意是:给定一个由数字123构成的数列,最少多少次交换可以使得其变成升序序列。 以前做过POJ上的USACO题中有类似的,大...

山中竹笋 109

[USACO Section 2.1] Sorting a Three-Valued Sequence (求排序最少交换次数)

题目大意: 排序是一种很频繁的计算任务。现在考虑最多只有三值的排序问题。一个实际的例子是,当我们给某项竞赛的优胜者按金银铜牌排序的时候。在这个任务中可能的值只有三种1,2和3。我们用交换的方法把他排成升序的。 写一个程序计算出,给定的一个1,2,3组成的数字序列,排成升序所需的最少交换次数。 解题思路: // 复杂度 O(N^2) // 先在输入的时候记录下1、2、3

SIOFive的专栏 1633

USACO - Chapter2 Section 2.1 - Sorting a Three-Valued Sequence

Sorting a Three-Valued Sequence

zhuo1ang的博客 286

USACO SECTION 2.1 Sorting a Three-Valued Sequence

Sorting a Three-Valued Sequence IOI'96 - Day 2 Sorting is one of the most frequently performed computational tasks. Consider the special sorting problem in which the records to be sorted have at

275

USACO-Section2.1 Sorting a Three-Valued Sequence(排序)

2017-8-7 题目描述 给定的一个1,2,3组成的数字序列,排成升序所需的最少交换次数 解答 将结果与所给情况进行比较,相等不用处理,对应相反直接交换即可,否则进行处理 代码 /* ID: 18795871 PROG: sort3 LANG: C++ */ #include&lt;iostream&gt; #include&lt;cstring&gt; #include...

qq_34600424的博客 268

USACO Section 2.1 Sorting A Three-Valued Sequence

好题,自己想没想出来,虽然大家都说是水题 1 /* ID:linyvxi1 2 PROB:sort3 3 LANG:C++ 4 */ 5 #include <stdio.h> 6 #include <algorithm> 7 using namespace std; 8 int start_pos[1005]; 9 int final_pos[10...

weixin_33963594的博客 77

USACO-Section2.1 Sorting a Three-Valued Sequence[排序]

2017-7-14题目一串由1,2,3组成的数字,用交换的方法从小到大排序,问最少交换次数。题解我用了一个表,把队列分3块吧,每个数有它应该在的位置,s[i][j]=n表示数字i有n个在数字j的位置上。那么i=j的就是已经在位置上了,ij互换的比如说s12和s21,取其中小的一个,表示两个数互换一次就能两个都到位。相同地s13和s31,s23和s32都是这么操作。 互换完后,剩下的数是三个数刚好形

xcwhkh的博客 356

USACO Section 2.1 Sorting A Three_Valued Sequence - 应该有更好的方法

题目的意思是有一列数只由1,2,3组成~~~需要咱们将1放在一起排在最前面~~~2放在一起排在中间~~~3放在一起放后面~~问对于这个数列最少要进行多少次交换...     我的方法是先统计1,2,3的个数~~那么就可以知道1,2,3分辨该放在哪个区域~~     首先将1都放到该放的位置~~其所需步数就是找2~3的区域中1的个数~~然后再看1这个区域里有多少个2可以直接和2区域的交换~~有多

zzyzzy12 952

USACO-Section2.1 Sorting a Three-Valued Sequence [其他][排序][交换]

题目大意 排序是一种很频繁的计算任务。现在考虑最多只有三值的排序问题。一个实际的例子是,当我们给某项竞赛的优胜者按金银铜牌排序的时候。在这个任务中可能的值只有三种1,2和3。我们用交换的方法把他排成升序的。 写一个程序计算出,给定的一个1,2,3组成的数字序列,排成升序所需的最少交换次数。 题解 NOCOW上给出过一种思路: 题意求排序所需的最少移动次数,可以先将输入的数字排序,

yoer77的博客 499
上一篇: USACO section 1.5 Checker Challenge(dfs深搜)
下一篇: USACO section 2.1 The Castle(dfs)
剑不飞
博客等级 码龄15年 86粉丝 505原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址