Submission #2305633


Source Code Expand

#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;

int n,s;
 
int replace(int n,char* s)
{
	int res=4;
	for(int i=0,j,k;i<16;i++){
		int pc=0;
		for(j=0,k=0;j<4 && k<n;j++,k++){
			pc+=i>>j&1;
			if(i>>j&1)
				k=find(s+k,s+n,"IJPC"[j])-s;
			if(k==n)
				break;
		}
		if(j==4)
			res=min(res,4-pc);
	}
	return res;
}

int main()
{
    cin >> n >> s;
    replace(n,s);
    return 0;
}

Submission Info

Submission Time
Task A - 国際情報オリンピック日本代表プログラミングコンテスト (Welcome to IJPC)
User luogu_bot4
Language C++ (GCC 5.4.1)
Score 0
Code Size 447 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:30:16: error: no matching function for call to ‘replace(int&, int&)’
     replace(n,s);
                ^
./Main.cpp:9:5: note: candidate: int replace(int, char*) <near match>
 int replace(int n,char* s)
     ^
./Main.cpp:9:5: note:   conversion of argument 2 would be ill-formed:
./Main.cpp:30:16: error: invalid conversion from ‘int’ to ‘char*’ [-fpermissive]
     replace(n,s);
                ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from ./Main.cpp:2:
/usr/include/c++/5/bits/stl_algo.h:4233:5: note: candidate: template<class _FIter, class _Tp> void std::replace(_FIter, _FIter, const _Tp&, const _Tp&)
     replace(_ForwardIterator __first, _ForwardIterator __last,
     ^
/usr/include/c++/5/bits/stl_algo.h:4233:5: note:   template argument deduction/substitution failed:
./Main.cpp:30:16: note:   candidate expects 4 arguments, 2 provided
     replace(n,s);
                ^