Submission #3419854
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define mx 15000000
#define MK 200005
#define pii pair<int,int>
#define tii pair<pii,int>
#define fs first
#define sc second
#define mp make_pair
int dp[105][105],ara[105],n;
int dp_func(int pos,int col)
{
if(pos>n)return 0;
if(dp[pos][col]!=-1)return dp[pos][col];
int ret=20000;
for(int i=1;i<=101;i++)
{
if(i==col)continue;
ret=min(ret,dp_func(pos+1,i)+(i!=ara[pos]));
}
return dp[pos][col]=ret;
}
int name[200000];
int main()
{
int id=0;
memset(dp,-1,sizeof dp);
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&ara[i]);
if(name[ara[i]]==0)
{
name[ara[i]]=++id;
}
ara[i]=name[ara[i]];
// cout<<ara[i]<<endl;
}
int ans=dp_func(1,0);
cout<<ans<<endl;
}
Submission Info
Submission Time
2018-10-17 03:24:18+0900
Task
A - Colorful Slimes 2
User
vjudge5
Language
C++14 (GCC 5.4.1)
Score
200
Code Size
865 Byte
Status
AC
Exec Time
4 ms
Memory
256 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:30:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:32:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&ara[i]);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
200 / 200
Status
Set Name
Test Cases
Sample
example_0, example_1, example_2, example_3
All
example_0, example_1, example_2, example_3, handmade_0, handmade_1, rand_0, rand_1, smallcolor_0, smallcolor_1, smallcolor_2, smallcolor_3, smallcolor_4
Case Name
Status
Exec Time
Memory
example_0
AC
1 ms
256 KB
example_1
AC
1 ms
256 KB
example_2
AC
1 ms
256 KB
example_3
AC
1 ms
256 KB
handmade_0
AC
1 ms
256 KB
handmade_1
AC
1 ms
256 KB
rand_0
AC
2 ms
256 KB
rand_1
AC
2 ms
256 KB
smallcolor_0
AC
4 ms
256 KB
smallcolor_1
AC
4 ms
256 KB
smallcolor_2
AC
4 ms
256 KB
smallcolor_3
AC
4 ms
256 KB
smallcolor_4
AC
4 ms
256 KB