zoukankan      html  css  js  c++  java
  • 【CodeForces】【#285】Div.2

    生平第一场Codeforce……纪念一下,虽然跪的跟渣渣似的……啊不就是跪成渣渣了……

    A、B暴力过去的……不知道会不会超时……C我犯了个2B错误,让输出总共多少条边,我都求出来边集E了……直接输出E.size()就行了……我居然还特么的自己用n去算!还找度数为0的点去减!WA了两次pretest……然后时间上浪费也好多……本来可以上2000分的T_T果然还是经验不足啊。

    A:

     1 #include<cstdio>
     2 #include<cstring>
     3 #include<cstdlib>
     4 #include<iostream>
     5 #include<algorithm>
     6 #define rep(i,n) for(int i=0;i<n;++i)
     7 #define F(i,j,n) for(int i=j;i<=n;++i)
     8 #define D(i,j,n) for(int i=j;i>=n;--i)
     9 using namespace std;
    10 
    11 int main(){
    12 //    freopen("input.txt","r",stdin);
    13     int a,b,c,d;
    14     scanf("%d%d%d%d",&a,&b,&c,&d);
    15     int val1=max(a*3/10,a-a*c/250),val2=max(b*3/10,b-b*d/250);
    16     if (val1>val2) printf("Misha
    ");
    17     else if (val1<val2) printf("Vasya
    ");
    18     else printf("Tie
    ");
    19     return 0;
    20 }
    View Code

    B:

     1 #include<cstdio>
     2 #include<cstring>
     3 #include<cstdlib>
     4 #include<iostream>
     5 #include<algorithm>
     6 #define rep(i,n) for(int i=0;i<n;++i)
     7 #define F(i,j,n) for(int i=j;i<=n;++i)
     8 #define D(i,j,n) for(int i=j;i>=n;--i)
     9 using namespace std;
    10 
    11 int cnt=0,num[1010];
    12 
    13 string oldname[1010],newname[1010];
    14 bool sign[2010];
    15 
    16 int main(){
    17     ios::sync_with_stdio(false);
    18 //    freopen("input.txt","r",stdin);
    19     int n;
    20     cin >> n;
    21     string s1,s2; int temp=0;
    22     
    23     F(i,1,n){
    24         temp=0;
    25         cin >> s1 >> s2;
    26         F(j,1,cnt) if (s1==newname[j]) {temp=j; break;}
    27         if (temp) newname[temp]=s2;
    28         else {oldname[++cnt]=s1; newname[cnt]=s2;}
    29     }
    30     cout <<cnt<<endl;
    31     F(i,1,cnt)
    32         cout << oldname[i]<<" "<<newname[i]<<endl;
    33     return 0;
    34 }
    View Code

    C:

     1 #include<cstdio>
     2 #include<queue>
     3 #include<vector>
     4 #include<cstring>
     5 #include<cstdlib>
     6 #include<iostream>
     7 #include<algorithm>
     8 #define rep(i,n) for(int i=0;i<n;++i)
     9 #define F(i,j,n) for(int i=j;i<=n;++i)
    10 #define D(i,j,n) for(int i=j;i>=n;--i)
    11 #define pb push_back
    12 using namespace std;
    13 const int N=100086;
    14 
    15 void read(int &v){
    16     v=0; int sig=1;
    17     char ch=getchar();
    18     while(ch<'0'||ch>'9'){ if (ch=='-') sig=-1; ch=getchar();}
    19     while(ch>='0'&&ch<='9'){ v=v*10+ch-'0'; ch=getchar();}
    20 }
    21 
    22 int degree[N],sum[N],a[N],b[N];
    23 queue<int>Q;
    24 struct edge{int from,to;};
    25 vector<edge>E;
    26 
    27 int main(){
    28 //    freopen("input.txt","r",stdin);
    29     int n;
    30     scanf("%d",&n);
    31     F(i,0,n-1)
    32         scanf("%d%d",&degree[i],&sum[i]);
    33     int ans=0;
    34     F(i,0,n-1)
    35         if (degree[i]==1) Q.push(i);
    36     
    37     while(!Q.empty()){
    38         int x=Q.front(); Q.pop();
    39         if (degree[x]<1) continue;
    40         degree[x]=0;
    41         
    42         E.pb((edge){x,sum[x]});
    43         degree[sum[x]]--;
    44         sum[sum[x]]^=x;
    45         if (degree[sum[x]]==1) Q.push(sum[x]); 
    46     }
    47     printf("%d
    ",E.size());
    48     rep(i,E.size())
    49         printf("%d %d
    ",E[i].from,E[i].to);
    50     return 0;
    51 }
    View Code

    D:(Orz vfleaking)

     1 伏特跳蚤国王(497446970) 22:22:34 
     2 a * 1! + b * 2! + c * 3! + ...
     3 a < 2, b < 3, c < 4 ...
     4 
     5 伏特跳蚤国王(497446970) 22:22:53 
     6 把大家表示成这个样子 = =||
     7 
     8 伏特跳蚤国王(497446970) 23:17:11 
     9 = =|||| 大家。。。就是。。所有数。。
    10 
    11 伏特跳蚤国王(497446970) 23:17:24 
    12 比如读进来的排列。。。把它的名次写成这个形式。。
    13 
    14 伏特跳蚤国王(497446970) 23:17:39 
    15 然后在这个形式下做加法。。
    16 
    17 Tunix(775712558) 23:18:24 
    18 !然后按找逐位递增的进制来进位?
    19 
    20 Tunix(775712558) 23:18:48 
    21 只保留后n位……?
    22 
    23 伏特跳蚤国王(497446970) 23:18:53 
    24 嗯 = =
    25 
    26 伏特跳蚤国王(497446970) 23:19:09 
    27 你既然都写成这个形式了。。加到 ?? * n! 这一位的时候
    28 
    29 伏特跳蚤国王(497446970) 23:19:14 
    30 就可以溜了
    VFK的讲解
     
  • 相关阅读:
    语句覆盖、判断覆盖、条件覆盖、条件判定组合覆盖、多条件覆盖、修正条件覆盖
    Python日志
    Python基础
    curl-awk-grep
    bash使用 变量定义与使用、预定义变量、数组变量、变量计算、掐头去尾与内容替换、数字比较大小、字符串比较、判断文件夹是否存在、逻辑控制if/for/while/
    V模型 W模型 H模型 X模型 前置测试模型
    算法:回文、素数
    JAVA并发思维导图
    工作常见的git命令
    dubbo同步/异步调用的方式
  • 原文地址:https://www.cnblogs.com/Tunix/p/4220056.html
Copyright © 2011-2022 走看看