从今天开始记录每一场cf。
历史性的第一场div3的比赛。
ac数量:4
rating变化:-5
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <iostream>
#include <stack>
#include <math.h>
#include <queue>
#include <vector>
#include <climits>
using namespace std;
const int Max_M= 1e3 + 10;
const int inf = 0x01010101;
int main()
{
// freopen("out.txt","w",stdout);
ios::sync_with_stdio(false);
int n,k;
cin.tie(0);
cin>>n>>k;
while(k--)
{
if(n%10)
n--;
else n/=10;
}
cout<<n<<endl;
return 0;
}
//A
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <iostream>
#include <stack>
#include <math.h>
#include <queue>
#include <vector>
#include <climits>
using namespace std;
const int Max_M= 1e3 + 10;
const int inf = 0x01010101;
int Count(string s,string pat)
{
int pos = 0,cnt = 0;
while(pos != -1)
{
pos = s.find(pat,pos+1);
if(pos != -1)break;
cnt++;
}
return cnt;
}
int main()
{
// freopen("out.txt","w",stdout);
ios::sync_with_stdio(false);
string s;
int n,mmax = -1;
cin.tie(0);
cin>>n>>s;
string ans ;
for(int i = 0; i < n - 1; i++)
{
int tmp = Count(s,s.substr(i,2));
if( tmp > mmax)
{
mmax = tmp;
ans = s.substr(i,2);
}
}
cout<<ans<<endl;
return 0;
}
//B
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <iostream>
#include <stack>
#include <math.h>
#include <queue>
#include <vector>
#include <climits>
using namespace std;
const int Max_M= 2e5 + 10;
const int inf = 0x01010101;
int a[Max_M];
int main()
{
// freopen("out.txt","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin>>n>>k;
for(int i = 0; i < n; i++)
cin>>a[i];
sort(a,a+n);
if(k == 0)
{
if(a[0] == 1)
cout<<"-1"<<endl;
else cout<<"1"<<endl;
return 0;
}
if(n == 1 || n == k)
{
cout<<a[k-1]<<endl;
return 0;
}
if(a[k-1] == a[k])
cout<<"-1"<<endl;
else cout<<a[k-1]<<endl;
return 0;
}
//C
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <iostream>
#include <stack>
#include <math.h>
#include <queue>
#include <vector>
#include <climits>
using namespace std;
typedef long long ll;
const int Max_M= 2e3 + 10;
const int inf = 0x01010101;
ll a[Max_M];
vector<ll> ans;
int flag;
bool used[Max_M];
int n;
void dfs(int index)
{
if(flag) return ;
if(index == n)
{
cout<<ans[0];
flag = 1;
for(int i = 1; i < ans.size(); i++)
cout<<" "<<ans[i];
cout<<endl;
return ;
}
for(int i = 0 ; i < n; i++)
{
if(used[i] == 1)continue;
if(index == 0)
{
for(int j = 0; j < n; j++)
{
used[j] = 1;
ans.push_back(a[j]);
dfs(index + 1);
ans.pop_back();
used[j] = 0;
}
}
if(a[i] * 3 == ans[ans.size()-1] || a[i] == ans[ans.size()-1] * 2)
{
used[i] = 1;
ans.push_back(a[i]);
dfs(index + 1);
}
ans.pop_back();
used[i] = 0;
}
}
int main()
{
// freopen("out.txt","w",stdout);
cin>>n;
for(int i = 0; i < n; i++)
scanf("%lld",&a[i]);
dfs(0);
return 0;
}
//D
#include <bits/stdc++.h>
using namespace std;
const int MAX_V = 2e5 + 10;
vector<int> G[MAX_V];
int n, m, flag;
bool visit[MAX_V];
void dfs(int index)
{
visit[index] = 1;
if (G[index].size() != 2)
flag = 0;
for (auto i : G[index])
if (!visit[i])
dfs(i);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
int a, b;
while (m--)
{
cin >> a >> b;
G[a].push_back(b);
G[b].push_back(a);
}
int ans = 0;
for (int i = 1; i <= n; i++)
{
flag = 1;
if (!visit[i]) //如果还没被访问过
{
dfs(i);
if (flag) ans++;
}
}
cout << ans << endl;
}//E
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <iostream>
#include <stack>
#include <math.h>
#include <queue>
#include <vector>
#include <climits>
#include <map>
using namespace std;
typedef long long ll;
const int Max_M= 2e5 + 10;
const int inf = 0x01010101;
map<int,int> T;
int a[Max_M];
int main()
{
// freopen("out.txt","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
int mmax = 0, k;
for(int i = 0; i < n; i++)
{
cin>>a[i];
T[a[i]] = T[a[i] - 1] + 1;
if(T[a[i]] > mmax)
{
mmax = T[a[i]];
k = a[i];
}
}
cout<<mmax<<endl;
int start = k - mmax + 1;
for(int i = 0; i < n && start <= k; i++)
{
if(a[i] == start)
{
cout<<i+1<<' ';
start++;
}
}
return 0;
}
//F