QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#296558#7857. (-1,1)-SumpleteDualqwq#Compile Error//C++201.5kb2024-01-03 10:07:312024-01-03 10:07:32

Judging History

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

  • [2024-01-03 10:07:32]
  • 评测
  • [2024-01-03 10:07:31]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 4e3 + 5;
int n;
char s[N][N];
int X[N],Y[N],srow[N],scol[N],usd[N][N];
char ans[N][N];
inline void Choose(int x,int y) {
	usd[x][y] = true;
	X[x]--;Y[y]--;ans[x][y] = s[x][y] == '+' ? '1' : '0';
}
int srtx[N],srty[N];
int main() {
	cin >> n;
	for(int i = 1;i <= n;i++) cin >> (s[i] + 1);
	for(int i = 1;i <= n;i++) cin >> X[i];
	for(int i = 1;i <= n;i++) cin >> Y[i];
	int sm = 0;
	for(int i = 1;i <= n;i++) sm += X[i] - Y[i];
	if(sm) return puts("NO"),0;
	for(int i = 1;i <= n;i++)
		for(int j = 1;j <= n;j++)
			if(s[i][j] == '-') srow[i]++,scol[j]++;
	for(int i = 1;i <= n;i++) X[i] += srow[i],Y[i] += scol[i],srtx[i] = i;
	for(int i = 1;i <= n;i++)
		if(X[i] < 0 || Y[i] < 0 || X[i] > n || Y[i] > n) return puts("NO"),0;
	// for(int i = 1;i <= n;i++) printf("(%d,%d)\n",X[i],Y[i]);
	sort(srtx + 1,srtx + n + 1,[&](const int &a,const int &b) { return X[a] > X[b];});
	for(int i = 1;i <= n;i++) {
		int u = srtx[i];//printf("u:%d,%d\n",u,X[u]);
		for(int j = 1;j <= n;j++) srty[j] = j;
		nth_element(srty + 1,srty + X[u],srty + n + 1,[&](const int &a,const int &b) { return Y[a] > Y[b];});
		for(int j = 1;X[u] > 0;j++) {
			if(!Y[srty[j]]) return puts("NO"),0;
			else Choose(u,srty[j]);
		} 
			
	}
	for(int i = 1;i <= n;i++) for(int j = 1;j <= n;j++) if(!usd[i][j]) ans[i][j] = (s[i][j] == '+') ? '0' : '1';
	puts("Yes");
	for(int i = 1;i <= n;i++) cout << (ans[i] + 1) << endl;
	return 0;
}	

详细

answer.code: In function ‘int main()’:
answer.code:15:39: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’)
   15 |         for(int i = 1;i <= n;i++) cin >> (s[i] + 1);
      |                                   ~~~ ^~ ~~~~~~~~~~
      |                                   |            |
      |                                   |            char*
      |                                   std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:168:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
  168 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:168:7: note:   conversion of argument 1 would be ill-formed:
answer.code:15:48: error: cannot bind non-const lvalue reference of type ‘bool&’ to a value of type ‘char*’
   15 |         for(int i = 1;i <= n;i++) cin >> (s[i] + 1);
      |                                          ~~~~~~^~~~
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:172:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match)
  172 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/11/istream:172:7: note:   conversion of argument 1 would be ill-formed:
answer.code:15:48: error: invalid conversion from ‘char*’ to ‘short int’ [-fpermissive]
   15 |         for(int i = 1;i <= n;i++) cin >> (s[i] + 1);
      |                                          ~~~~~~^~~~
      |                                                |
      |                                                char*
answer.code:15:48: error: cannot bind rvalue ‘(short int)(((char*)(& s[i])) + 1)’ to ‘short int&’
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:175:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
  175 |       operator>>(unsigned short& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:175:7: note:   conversion of argument 1 would be ill-formed:
answer.code:15:48: error: invalid conversion from ‘char*’ to ‘short unsigned int’ [-fpermissive]
   15 |         for(int i = 1;i <= n;i++) cin >> (s[i] + 1);
      |                                          ~~~~~~^~~~
      |                                                |
      |                                                char*
answer.code:15:48: error: cannot bind rvalue ‘(short unsigned int)(((char*)(& s[i])) + 1)’ to ‘short unsigned int&’
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:179:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match)
  179 |       operator>>(int& __n);
      |       ^~~~~~~~
/usr/include/c++/11/istream:179:7: note:   conversion of argument 1 would be ill-formed:
answer.code:15:48: error: invalid conversion from ‘char*’ to ‘int’ [-fpermissive]
   15 |         for(int i = 1;i <= n;i++) cin >> (s[i] + 1);
      |                                          ~~~~~~^~~~
      |                                                |
      |                                                char*
answer.code:15:48: error: cannot bind rvalue ‘(int)(((char*)(& s[i])) + 1)’ to ‘int&’
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gn...