提出 #70104273
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------
int T,N;
int Y[505];
int A[505][505];
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>T;
while(T--) {
cin>>N;
FOR(x,N) FOR(y,N) A[x][y]=0;
int S=-1;
deque<int> D;
FOR(y,N) {
cin>>x;
x--;
A[y][x]=1;
if(y==x) {
S=y;
}
else if(x<y) {
D.push_front(x);
D.push_back(y);
}
}
D.push_front(S);
int ok=1;
FOR(y,N) FOR(x,N) if(A[y][x]==1) {
if(A[x][y]!=1) ok=0;
}
assert(N%2==0);
if(ok==0||N%2==0||D.size()!=N) {
cout<<"No"<<endl;
continue;
}
FOR(i,N) {
A[D[0]][D[0]]=i+1;
FOR(j,N/2) {
A[D[1+j]][D[N-1-j]]=i+1;
A[D[N-1-j]][D[1+j]]=i+1;
}
rotate(D.begin(),D.begin()+1,D.end());
}
cout<<"Yes"<<endl;
FOR(y,N) {
FOR(x,N) cout<<A[y][x]<<" ";
cout<<endl;
}
}
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
cout.tie(0); solve(); return 0;
}
提出情報
| 提出日時 |
|
| 問題 |
D - Symmetric Matrix |
| ユーザ |
kmjp |
| 言語 |
C++ 20 (gcc 12.2) |
| 得点 |
0 |
| コード長 |
1639 Byte |
| 結果 |
RE |
| 実行時間 |
76 ms |
| メモリ |
4632 KiB |
コンパイルエラー
Main.cpp: In function ‘void solve()’:
Main.cpp:47:43: warning: comparison of integer expressions of different signedness: ‘std::deque<int>::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
47 | if(ok==0||N%2==0||D.size()!=N) {
| ~~~~~~~~^~~
Main.cpp:21:17: warning: unused variable ‘k’ [-Wunused-variable]
21 | int i,j,k,l,r,x,y; string s;
| ^
Main.cpp:21:19: warning: unused variable ‘l’ [-Wunused-variable]
21 | int i,j,k,l,r,x,y; string s;
| ^
Main.cpp:21:21: warning: unused variable ‘r’ [-Wunused-variable]
21 | int i,j,k,l,r,x,y; string s;
| ^
Main.cpp: In function ‘int main(int, char**)’:
Main.cpp:6:19: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
6 | #define FOR(x,to) for(x=0;x<(to);x++)
| ^~~
Main.cpp:73:9: note: in expansion of macro ‘FOR’
73 | FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
| ^~~
Main.cpp:6:19: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
6 | #define FOR(x,to) for(x=0;x<(to);x++)
| ^~~
Main.cpp:73:45: note: in expansion of macro ‘FOR’
73 | FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
| ^~~
Main.cpp:6:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
6 | #define FOR(x,to) for(x=0;x<(to);x++)
| ^
Main.cpp:73:45: note: in expansion of macro ‘FOR’
73 | FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
| ^~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
0 / 700 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
00_sample_00.txt |
| All |
00_sample_00.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt, 02_random_20.txt, 02_random_21.txt, 02_random_22.txt, 02_random_23.txt, 02_random_24.txt, 02_random_25.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00_sample_00.txt |
RE |
76 ms |
3484 KiB |
| 01_handmade_00.txt |
WA |
1 ms |
4504 KiB |
| 01_handmade_01.txt |
WA |
1 ms |
4500 KiB |
| 01_handmade_02.txt |
RE |
76 ms |
3604 KiB |
| 01_handmade_03.txt |
RE |
75 ms |
3600 KiB |
| 02_random_00.txt |
AC |
1 ms |
4632 KiB |
| 02_random_01.txt |
AC |
1 ms |
4500 KiB |
| 02_random_02.txt |
AC |
1 ms |
4448 KiB |
| 02_random_03.txt |
RE |
76 ms |
4492 KiB |
| 02_random_04.txt |
RE |
76 ms |
4492 KiB |
| 02_random_05.txt |
RE |
76 ms |
4468 KiB |
| 02_random_06.txt |
AC |
1 ms |
4436 KiB |
| 02_random_07.txt |
RE |
76 ms |
4524 KiB |
| 02_random_08.txt |
RE |
75 ms |
4604 KiB |
| 02_random_09.txt |
RE |
76 ms |
4416 KiB |
| 02_random_10.txt |
RE |
76 ms |
4452 KiB |
| 02_random_11.txt |
WA |
1 ms |
4428 KiB |
| 02_random_12.txt |
WA |
1 ms |
4512 KiB |
| 02_random_13.txt |
WA |
1 ms |
4516 KiB |
| 02_random_14.txt |
WA |
1 ms |
4572 KiB |
| 02_random_15.txt |
WA |
1 ms |
4496 KiB |
| 02_random_16.txt |
WA |
1 ms |
4428 KiB |
| 02_random_17.txt |
RE |
76 ms |
3612 KiB |
| 02_random_18.txt |
RE |
75 ms |
3632 KiB |
| 02_random_19.txt |
WA |
1 ms |
3708 KiB |
| 02_random_20.txt |
WA |
1 ms |
3652 KiB |
| 02_random_21.txt |
RE |
76 ms |
3588 KiB |
| 02_random_22.txt |
RE |
76 ms |
3648 KiB |
| 02_random_23.txt |
RE |
75 ms |
3616 KiB |
| 02_random_24.txt |
RE |
75 ms |
3616 KiB |
| 02_random_25.txt |
RE |
75 ms |
3804 KiB |