In the ocean full of whites, blues, reds, I really like this color: AC
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
In the ocean full of whites, blues, reds, I really like this color: AC
I am newbie in Competetive Programming . I would very much appreciate some help from you guys. Are there any problemsets available from Beginner to Advanced level that would help me improve my CP step by step ? Thank You
I was trying to solve this simple DP question 219C - Color Stripe and my solution is working well in the text editor for C++ 17 , but it gives WA on sample cases here.. Please help. Code:-
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi(x) vector<x>
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define mii map<int,int>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,k;
cin>>n>>k;
string s;
cin>>s;
int dp[n][k];
for(int i=0;i<n;i++)
for(int j=0;j<k;j++)
dp[i][j]=MOD;
string dps[n][k];
for(int i=0;i<k;i++)
{
dp[0][i]=1;
dps[0][i]+=('A'+i);
}
dp[0][s[0]-'A']=0;
for(int i=1;i<n;i++)
{
for(int j=0;j<k;j++)
{
int in=-1;
for(int l=0;l<k;l++)
{
if(l!=j)
{
if(dp[i][j]>dp[i-1][l])
{
dp[i][j]=dp[i-1][l];
in=l;
}
}
}
int x=s[i]-'A';
if(j!=x)
dp[i][j]++;
string t;
t+=('A'+j);
dps[i][j]=dps[i-1][in]+t;
}
}
int ans=MOD,in=-1;
for(int i=0;i<n;i++)
{
if(ans>dp[n-1][i])
{
ans=min(ans,dp[n-1][i]);
in=i;
}
}
cout<<ans<<endl;
cout<<dps[n-1][in]<<endl;
return 0;
}
Can anyone please provide a good tutorial on how to find the Minimum Vetex Cover of a graph ? P.S- Please don't provide geeks for geeks links.
Название |
---|