QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#692516#5520. Distance Paritiescppcppcpp3Compile Error//C++20917b2024-10-31 14:38:532024-10-31 14:39:16

Judging History

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

  • [2024-10-31 14:39:16]
  • 评测
  • [2024-10-31 14:38:53]
  • 提交

answer

#include<bits/stdc++.h>
#define FIO(file) freopen(file".in","r",stdin),freopen(file".out","w",stdout)
using namespace std;
const int N=505;

int n,m,f[N][N];
char a[N][N];

void solve(){
	cin>>n,m=0;
	for(int i=1;i<=n;++i) cin>>(a[i]+1);
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			f[i][j]=(i==j?0:a[i][j]=='1'?1:n),m+=(a[i][j]=='1');
		}
	}
	m>>=1;
	for(int k=1;k<=n;++k)
		for(int i=1;i<=n;++i)
			for(int j=1;j<=n;++j)
				f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			if(f[i][j]>=n){cout<<"NO\n";return;}
			if((f[i][j]&1)!=(a[i][j]-'0')){cout<<"NO\n";return;}
		}
	}
	cout<<"YES\n";
	cout<<m<<"\n";
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
			if(a[i][j]=='1') cout<<i<<' '<<j<<"\n";
}

signed main(){
	// FIO("bridge");
	cin.tie(nullptr)->sync_with_stdio(false);
	int T; cin>>T;
	while(T--) solve();
	return 0;
}

詳細信息

answer.code: In function ‘void solve()’:
answer.code:11:34: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’)
   11 |         for(int i=1;i<=n;++i) cin>>(a[i]+1);
      |                               ~~~^~~~~~~~~~
      |                               |         |
      |                               |         char*
      |                               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:11:41: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’
   11 |         for(int i=1;i<=n;++i) cin>>(a[i]+1);
      |                                    ~~~~~^~~
/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:11:41: error: invalid conversion from ‘char*’ to ‘long long unsigned int’ [-fpermissive]
   11 |         for(int i=1;i<=n;++i) cin>>(a[i]+1);
      |                                    ~~~~~^~~
      |                                         |
      |                                         char*
answer.code:11:41: error: cannot bind rvalue ‘(long long unsigned int)(((char*)(& a[i])) + 1)’ to ‘long long unsigned int&’
/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:11:41: error: invalid conversion from ‘char*’ to ‘long long int’ [-fpermissive]
   11 |         for(int i=1;i<=n;++i) cin>>(a[i]+1);
      |                                    ~~~~~^~~
      |                                         |
      |                                         char*
answer.code:11:41: error: cannot bind rvalue ‘(long long int)(((char*)(& a[i])) + 1)’ to ‘long long int&’
/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:11:41: error: invalid conversion from ‘char*’ to ‘long unsigned int’ [-fpermissive]
   11 |         for(int i=1;i<=n;++i) cin>>(a[i]+1);
      |                                    ~~~~~^~~
      |                                         |
      |                                         char*
answer.code:11:41: error: cannot bind rvalue ‘(long unsigned int)(((char*)(& a[i])) + 1)’ to ‘long unsigned int&’
/usr/include/c++/13/istream:188:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  188 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:188:7: note:   conversion of argument 1 would be ill-formed:
answer.code:11:41: error: invalid conversion from ‘char*’ to ‘long int’ [-fpermissive]
   11 |         for(int i=1;i<=n;++i) cin>>(a[i]+1);
      |                                    ~~~~~^~~
      |                                         |
      |                                         char*
answer.code:11:41: error: cannot bind rvalue ‘(long int)(((char*)(& a[i])) + 1)’ to ‘long int&’
/usr/include/c++/13/istream:184:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_t...