QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#505089 | #2833. Hamilton | Southern_Dynasty | WA | 0ms | 4048kb | C++14 | 2.3kb | 2024-08-04 19:43:01 | 2024-08-04 19:43:01 |
Judging History
answer
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define gt getchar
#define pt putchar
#define fst first
#define scd second
#define SZ(s) ((int)s.size())
#define all(s) s.begin(),s.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int uint;
const int N=2005;
using namespace std;
using namespace __gnu_pbds;
typedef pair<int,int> pii;
template<class T,class I> inline void chkmax(T &a,I b){a=max(a,(T)b);}
template<class T,class I> inline void chkmin(T &a,I b){a=min(a,(T)b);}
inline bool __(char ch){return ch>=48&&ch<=57;}
template<class T> inline void read(T &x){
x=0;bool sgn=0;static char ch=gt();
while(!__(ch)&&ch!=EOF) sgn|=(ch=='-'),ch=gt();
while(__(ch)) x=(x<<1)+(x<<3)+(ch&15),ch=gt();
if(sgn) x=-x;
}
template<class T,class ...I> inline void read(T &x,I &...x1){
read(x);
read(x1...);
}
template<class T> inline void print(T x){
static char stk[70];short top=0;
if(x<0) pt('-');
do{stk[++top]=x>=0?(x%10+48):(-(x%10)+48),x/=10;}while(x);
while(top) pt(stk[top--]);
}
template<class T> inline void printsp(T x){
print(x);
putchar(' ');
}
template<class T> inline void println(T x){
print(x);
putchar('\n');
}
int n,e[N][N];
inline void solve(){
for(int i=1;i<=n;++i){
for(int j=1;j<=n;++j){
scanf("%1d",&e[i][j]);
}
}
vector<int> cyc={1,2};
for(int i=3;i<=n;++i){
int m=i-1;
set<int> st;
for(int x=0;x<m;++x){
int y=(x+1)%m;
st.insert(e[cyc[x]][cyc[y]]);
}
if(SZ(st)==1){
int lst=cyc.back();
cyc.pop_back();
cyc.eb(i);
cyc.eb(lst);
}else{
for(int C=0;C<m;++C){
int B=C?C-1:m-1;
int D=(C+1)%m;
if(!e[cyc[B]][cyc[C]]&&e[cyc[C]][cyc[D]]){
if(e[i][cyc[C]]){
vector<int> vec;
for(int j=0;j<C;++j) vec.eb(cyc[j]);
vec.eb(i);
for(int j=C;j<SZ(cyc);++j) vec.eb(cyc[j]);
}else{
vector<int> vec;
for(int j=0;j<=C;++j) vec.eb(cyc[j]);
vec.eb(i);
for(int j=C+1;j<SZ(cyc);++j) vec.eb(cyc[j]);
}
break;
}
}
}
}
for(int v:cyc) printsp(v);
printf("\n");
}
signed main(){
while(~scanf("%d",&n)) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4048kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
1 3 2 1 3 4 2
result:
ok 2 cases.
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 4040kb
input:
3 000 000 000 3 010 100 000 3 011 100 100 3 011 101 110
output:
1 3 2 1 3 2 1 3 2 1 3 2
result:
wrong answer case #3: found 2 indices