QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#642584#7778. Turning PermutationSCAU_xyjkanadeCompile Error//C++172.8kb2024-10-15 15:05:372024-10-15 15:05:38

Judging History

你现在查看的是最新测评结果

  • [2024-10-15 15:05:38]
  • 评测
  • [2024-10-15 15:05:37]
  • 提交

answer

#include <bits/stdc++.h>
#define int __int128 
using namespace std;
const int N = 60;
int n;
long long k;
int ans[N];
long long dp[N][N];
int vis[N];
int fx;
int fir ;
long long sol(int bg) // the begin dp position [bg,n]
{
	if(bg > n)return 1;
	if(!fx || bg == 2)
	{
		if(fir % 2 == 1)fx = 1;
		else fx = 2;
	}
	long long ret = 0;
	int cnt = 0;
	memset(dp,0,sizeof(dp));
	if(fx == 1)///偶数在奇数右边 
	{
		for(int i = 1;i <= n;i++)
		{
			if(vis[i])continue;
			++cnt;
			if(i % 2 == 1)
			{
				if(vis[i - 1] || vis[i + 1])return 0;	
			} 
			if(cnt == 1)
			{
				for(int j = 1;j <= n - bg + 1;j++)
					dp[cnt][j] = 1;
			}
			if(vis[i - 1])
			{
				for(int j = 1;j <= n - bg + 1 - cnt + 1;j++)
				{
					for(int k = 1;k <= n - bg + 1 - cnt + 2;k++)
					{
						dp[cnt][j] += dp[cnt - 1][k];
					}
				}
			}
			else 
			for(int j = 1;j <= n - bg + 1 - cnt + 1;j++)//dp[cnt][j] 
			{
				if(i % 2 == 1)
				{
					for(int k = j + 1;k <= n - bg + 1 - cnt + 2;k++)
						dp[cnt][j] += dp[cnt - 1][k];					
				} 
				else
				{
					for(int k = 1;k <= j;k++)
						dp[cnt][j] += dp[cnt - 1][k];
				}
			}
		}
	}
	
	else if(fx == 2)///偶数在奇数左边 
	{
		for(int i = 1;i <= n;i++)
		{
			if(vis[i])continue;
			++cnt;
			if(i % 2 == 0)
			{
				if(vis[i - 1] || vis[i + 1])return 0;	
			} 
			if(cnt == 1)
			{
				for(int j = 1;j <= n - bg + 1;j++)
					dp[cnt][j] = 1;
			}
			if(vis[i - 1])
			{
				for(int j = 1;j <= n - bg + 1 - cnt + 1;j++)
				{
					for(int k = 1;k <= n - bg + 1 - cnt + 2;k++)
					{
						dp[cnt][j] += dp[cnt - 1][k];
					}
				}
			}
			else 
			for(int j = 1;j <= n - bg + 1 - cnt + 1;j++)//dp[cnt][j] 
			{
				if(i % 2 == 0)
				{
					for(int k = j + 1;k <= n - bg + 1 - cnt + 2;k++)
						dp[cnt][j] += dp[cnt - 1][k];					
				} 
				else
				{
					for(int k = 1;k <= j;k++)
						dp[cnt][j] += dp[cnt - 1][k];
				}
			}
		}
	}	
	return dp[cnt][1];
}
signed main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n;
	cin >> k;
	int flag = 1;
/*	if(n == 30)
	{
		cout << "1 6 2 3 4 5 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 ";
		return 0;
	}*/
	for(int i = 1;i <= n;i++)
	{
		for(int j = 1;j <= n;j++)
		{
			if(vis[j]) continue;
			if(i == 1)fir = j;
			vis[j] = 1;
			long long tt = sol(i + 1);
			//if(i == 1)cout << j << " " << tt << endl;
			if(tt < k)k -= tt;
			else 
			{
				ans[i] = j;
				flag = 0;
				break;
			}
			vis[j] = 0;
		}
		if(i == 1 && flag == 1)
		{
			cout << -1;
			return 0;
		}
	}
	//cout << k << endl;
	for(int i = 1;i <= n;i++)
	{
		/*if(ans[i])*/
			cout << ans[i] << " ";
		/*else {
			for(int i = 1;i <= n;i++)
				if(!vis[i])
				{
					cout << i << " ";
					break;
				}
					
		}*/
	}
		
	return 0;
} 

Details

answer.code: In function ‘int main()’:
answer.code:111:13: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘__int128’)
  111 |         cin >> n;
      |         ~~~ ^~ ~
      |         |      |
      |         |      __int128
      |         std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/13/sstream:40,
                 from /usr/include/c++/13/complex:45,
                 from /usr/include/c++/13/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127,
                 from answer.code:1:
/usr/include/c++/13/istream:325:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  325 |       operator>>(void*& __p)
      |       ^~~~~~~~
/usr/include/c++/13/istream:325:7: note:   conversion of argument 1 would be ill-formed:
answer.code:111:16: error: invalid conversion from ‘__int128’ to ‘void*’ [-fpermissive]
  111 |         cin >> n;
      |                ^
      |                |
      |                __int128
answer.code:111:16: error: cannot bind rvalue ‘(void*)((long int)n)’ to ‘void*&’
/usr/include/c++/13/istream:224:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  224 |       operator>>(long double& __f)
      |       ^~~~~~~~
/usr/include/c++/13/istream:224:7: note:   conversion of argument 1 would be ill-formed:
answer.code:111:16: error: cannot bind non-const lvalue reference of type ‘long double&’ to a value of type ‘__int128’
  111 |         cin >> n;
      |                ^
/usr/include/c++/13/istream:220:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  220 |       operator>>(double& __f)
      |       ^~~~~~~~
/usr/include/c++/13/istream:220:7: note:   conversion of argument 1 would be ill-formed:
answer.code:111:16: error: cannot bind non-const lvalue reference of type ‘double&’ to a value of type ‘__int128’
  111 |         cin >> n;
      |                ^
/usr/include/c++/13/istream:216:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  216 |       operator>>(float& __f)
      |       ^~~~~~~~
/usr/include/c++/13/istream:216:7: note:   conversion of argument 1 would be ill-formed:
answer.code:111:16: error: cannot bind non-const lvalue reference of type ‘float&’ to a value of type ‘__int128’
  111 |         cin >> n;
      |                ^
/usr/include/c++/13/istream:201:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  201 |       operator>>(unsigned long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:201:7: note:   conversion of argument 1 would be ill-formed:
answer.code:111:16: error: cannot bind non-const lvalue reference of type ‘long long unsigned int&’ to a value of type ‘__int128’
  111 |         cin >> n;
      |                ^
/usr/include/c++/13/istream:197:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  197 |       operator>>(long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:197:7: note:   conversion of argument 1 would be ill-formed:
answer.code:111:16: error: cannot bind non-const lvalue reference of type ‘long long int&’ to a value of type ‘__int128’
  111 |         cin >> n;
      |                ^
/usr/include/c++/13/istream:192:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  192 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:192:7: note:   conversion of argument 1 would be ill-formed:
answer.code:111:16: error: cannot bind non-const lvalue reference of type ‘long unsigned int&’ to a value of type ‘__int128’
  111 |         cin >> n;
      |                ^
/usr/include/c++/13/istream:188:7: no...