QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#600161#5523. Graph Problem With Small $n$manizareWA 293ms36656kbC++141.2kb2024-09-29 15:05:542024-09-29 15:05:54

Judging History

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

  • [2024-09-29 15:05:54]
  • 评测
  • 测评结果:WA
  • 用时:293ms
  • 内存:36656kb
  • [2024-09-29 15:05:54]
  • 提交

answer

#include <bits/stdc++.h>

#pragma GCC optimize("O3,unroll-loops") 
#define pb push_back
#define F first
#define S second
#define sz(a) (int)a.size()
#define pii pair<int,int> 
#define rep(i , a , b) for(int i = (a) ; i <= (b) ; i++)
#define per(i , a , b) for(int i = (a) ; i >= (b) ; i--)
#define all(a) a.begin(),a.end() 
#define ld long double

using namespace std ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn =5e6 + 10 , mod = 998244353 , inf= 1e9;;

int e[maxn] , dp[maxn] ,ans[30] ; 

signed main(){
    ios::sync_with_stdio(0);cin.tie(0);
	int n ;
	cin >> n ; 
	rep(i , 0 ,n-1){
		rep(j ,0 ,n-1){
			char f;
			cin >> f; 
			if(f=='1')
			e[i] += (1<<j) ;
		}
	}
	dp[1] = 1; 
	rep(i , 1 , (1<<n)-1){
		if(i%2==0)continue ; 
		rep(j , 0 ,n-1){
			if(i>>j&1)continue ; 
			if((dp[i]&e[j])!=0){
				dp[i+(1<<j)] |= (1<<j) ; 
			}			
		}
	}
	rep(i , 0 , (1<<n)-1){
		if(i%2==1)continue ; 
		int a = (i|1) , b = ((((1<<n)-1)^i)|1); 
		rep(j ,0 , n-1){
			if(dp[a]>>j&1){
				ans[j] |= dp[b];  
			}	
		}
	}
	rep(i ,0 , n-1){
		rep(j ,0 ,n-1){
			int x = (ans[i]>>j&1) ;
			cout << x ;
		}
		cout <<"\n"; 
	}
}
/*

*/

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 5836kb

input:

4
0110
1010
1101
0010

output:

0001
0001
0000
1100

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 5672kb

input:

6
010001
101000
010100
001010
000101
100010

output:

010001
101000
010100
001010
000101
100010

result:

ok 6 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 5768kb

input:

4
0111
1011
1101
1110

output:

0111
1011
1101
1110

result:

ok 4 lines

Test #4:

score: 0
Accepted
time: 288ms
memory: 3552kb

input:

23
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
000000000...

output:

00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
000000000000...

result:

ok 23 lines

Test #5:

score: 0
Accepted
time: 287ms
memory: 13912kb

input:

23
00010100000000000101000
00000000010000000001000
00000000000001000000001
10000000000000000010000
00000000000000000000000
10000000000000000000000
00000001000000000000000
00000010000000000010000
00000000000001000000000
01000000000000000000000
00000000000000000000000
00000000000000000000000
000000000...

output:

00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
000000000000...

result:

ok 23 lines

Test #6:

score: 0
Accepted
time: 293ms
memory: 36656kb

input:

23
00001000000000000000000
00001000010001000000000
00000000000101000010000
00001000000100000000000
11010000010011000100000
00000000000100000000000
00000000000000000000001
00000000000000000101000
00000000000000000000000
01001000000000101010010
00000000000000000000101
00110100000010001000000
000010000...

output:

00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
000000000000...

result:

ok 23 lines

Test #7:

score: -100
Wrong Answer
time: 293ms
memory: 36584kb

input:

23
01000000000001101001100
10000001101000000000000
00000100000100010000100
00000000000000001011000
00000100001000000000000
00101000000000001000001
00000000000000000000000
01000000000000000000000
01000000000100000010000
00000000000001000000011
01001000000000010000000
00100000100001000100001
000000000...

output:

00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000001000000000000000
00000000000000000000000
00000100000010001100100
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
000000010000...

result:

wrong answer 6th lines differ - expected: '00000000000000000000000', found: '00000001000000000000000'