답안 #17862

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
17862 2016-01-12T14:37:54 Z Erzhann K번째 경로 (IZhO11_kthpath) C++
컴파일 오류
0 ms 0 KB
/*
  /\     /\
  | ).|.( |
  |  >-<  |
  =========
It's AdilkhanKo miaaaaaau      
*/
#include<bits/stdc++.h>

#define ll long long
#define pb push_back
#define endl "\n"
#define foreach(it, S) for(__typeof (S.begin()) it = S.begin(); it != S.end(); it++)
#define mp make_pair
#define f first
#define s second 
#define name ""
#define _ ios_base::sync_with_stdio(false);cin.tie(0);

using namespace std;
                                            
const int MaxN = int (2e5) + 256;
const int INF = int(1e9);  
const int mod = (int)(1e9) + 7;
ll n, a[44][44], k, m, t;
char c[44][44];
string ans;

void rec(int x, int y){
	ans = ans + c[x][y];
	if(x == n && y == m){
		return;
	}
	char r, v;
	if(x + 1 <= n){
		v = c[x + 1][y];
	}else{
		rec(x, y + 1);
	}
	if(y + 1 <= m){
		r = c[x][y + 1];
	}else{
		rec(x + 1, y);
	}
	if(r <= v){
		int I = n - x + 1;
		int J = m - y;
		if(a[I][J] >= k){
			rec(x, y + 1);			
		}else{
			k -= a[I][J];
			rec(x + 1, y);
		}		
	}else{
		int I = n - x;
		int J = m - y + 1;
		if(a[I][J] >= k)
			rec(x + 1, y);
		else{
			k -= a[I][J];
			rec(x, y + 1);
		}
	}
}
int main () { _
	/*#ifdef ONLINE_JUDGE
		freopen (name".in","r",stdin);
		freopen (name".out","w",stdout);
	#else
		freopen (".in","r",stdin);
		freopen (".out","w",stdout);
	#endif */
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			cin >> c[i][j];
		}
	}
	cin >> k;
	for(int i = 2; i <= m; i++)
		a[1][i] = 1;
	for(int i = 2; i <= n; i++){
		a[i][1] = 1;
		for(int j = 2; j <= m; j++){
			a[i][j] = a[i - 1][j] + a[i][j - 1];
		}
	}
	cout << a[n][m] << endl;
	rec(1, 1);
	ans = 
	cout << ans << endl;
return 0;
}                   									

Compilation message

kthpath.cpp: In function 'int main()':
kthpath.cpp:90:6: error: ambiguous overload for 'operator=' (operand types are 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}' and 'std::basic_ostream<char>')
  ans = 
      ^
In file included from /usr/include/c++/5/string:52:0,
                 from /usr/include/c++/5/bitset:47,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:65,
                 from kthpath.cpp:8:
/usr/include/c++/5/bits/basic_string.h:558:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>] <near match>
       operator=(const _CharT* __s)
       ^
/usr/include/c++/5/bits/basic_string.h:558:7: note:   conversion of argument 1 would be ill-formed:
kthpath.cpp:91:14: error: invalid user-defined conversion from 'std::basic_ostream<char>' to 'const char*' [-fpermissive]
  cout << ans << endl;
              ^
In file included from /usr/include/c++/5/ios:44:0,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:66,
                 from kthpath.cpp:8:
/usr/include/c++/5/bits/basic_ios.h:120:7: note: candidate is: std::basic_ios<_CharT, _Traits>::operator void*() const [with _CharT = char; _Traits = std::char_traits<char>] <near match>
       operator void*() const
       ^
/usr/include/c++/5/bits/basic_ios.h:120:7: note:   no known conversion from 'void*' to 'const char*'
In file included from /usr/include/c++/5/string:52:0,
                 from /usr/include/c++/5/bitset:47,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:65,
                 from kthpath.cpp:8:
/usr/include/c++/5/bits/basic_string.h:569:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>] <near match>
       operator=(_CharT __c)
       ^
/usr/include/c++/5/bits/basic_string.h:569:7: note:   conversion of argument 1 would be ill-formed:
kthpath.cpp:91:14: error: invalid user-defined conversion from 'std::basic_ostream<char>' to 'char' [-fpermissive]
  cout << ans << endl;
              ^
In file included from /usr/include/c++/5/ios:44:0,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:66,
                 from kthpath.cpp:8:
/usr/include/c++/5/bits/basic_ios.h:120:7: note: candidate is: std::basic_ios<_CharT, _Traits>::operator void*() const [with _CharT = char; _Traits = std::char_traits<char>] <near match>
       operator void*() const
       ^
/usr/include/c++/5/bits/basic_ios.h:120:7: note:   no known conversion from 'void*' to 'char'