QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#539040#7857. (-1,1)-SumpleteJEdwardAC ✓664ms254444kbC++172.8kb2024-08-31 13:50:512024-08-31 13:50:51

Judging History

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

  • [2024-08-31 13:50:51]
  • 评测
  • 测评结果:AC
  • 用时:664ms
  • 内存:254444kb
  • [2024-08-31 13:50:51]
  • 提交

answer

#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define int long long
#define endl '\n'
#define lowbit(x) (x)&(-x)
#define pii pair<int,int>
#define pb push_back
#define all(s) s.begin(), s.end()
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define here system("pause")
using namespace std;
template <class T> inline void read(T& x) { x = 0; char c = getchar(); bool f = 0; for (; !isdigit(c); c = getchar()) f ^= (c == '-'); for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48); x = f ? -x : x; }
template <class T> inline void write(T x) { if (x < 0) putchar('-'), x = -x; if (x < 10) putchar(x + 48); else write(x / 10), putchar(x % 10 + 48); }
template<typename T> void chkmin(T& lhs, const T& rhs) { lhs = lhs > rhs ? rhs : lhs; }
template<typename T> void chkmax(T& lhs, const T& rhs) { lhs = lhs < rhs ? rhs : lhs; }

const int N = 4e3+5;
const int mod = 1e9+7;
const int INF = 8e18+7;
const double eps = 1e-6;
inline int pow(int a, int b, int p){ int res = 1%p; while(b){ if(b&1) res=res*a%p; a=a*a%p, b>>=1;} return res;}
inline int inv(int a, int p){ return pow(a,p-2,p)%p;}
mt19937_64 rnd(chrono::duration_cast< chrono::nanoseconds>(chrono::system_clock::now().time_since_epoch()).count());
int randint(int L, int R) {
	uniform_int_distribution<int> dist(L, R);
	return dist(rnd);
}
using ull = unsigned long long;

int n;
int a[N][N];
int R[N], C[N];
int vis[N][N];

inline void select(int i, int j){
	vis[i][j] ^= 1;
	R[i] += a[i][j];
	C[j] += a[i][j];
	a[i][j] = -a[i][j];
}

inline void sol(){
	cin >> n;
	for(int i=1;i<=n;i++){
		string s;
		cin >> s;
		for(int j=0;j<n;j++){
			a[i][j+1] = s[j] == '+' ? 1 : -1;
		}
	}
	
	for(int i=1;i<=n;i++){
		cin >> R[i];
		R[i] = -R[i];
	}
	for(int i=1;i<=n;i++){
		cin >> C[i];
		C[i] = -C[i];
	}
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(a[i][j] == 1){
				select(i, j);
			}
		}
	}
	
	for(int i=1;i<=n;i++){
		if(R[i] < 0 || C[i] < 0) return cout << "No\n", void();
	}
	
	vector<int> r(n), c(n);
	iota(all(r), 1);
	iota(all(c), 1);
	sort(all(r), [&](const int &a, const int &b){
		return R[a] > R[b];
	});
	for(int x : r){
		sort(all(c), [&](const int &a, const int &b){
			return C[a] > C[b];
		});
		for(int y : c){
			if(R[x] <= 0) break;
			if(C[y] > 0) select(x, y);
		}
	}
	
	for(int i=1;i<=n;i++){
		if(R[i] || C[i]) return cout << "No\n", void();
	}
	
	cout << "Yes\n";
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cout << vis[i][j];
		}
		cout << endl;
	}
}


signed main(){
#ifdef LOCAL
	clock_t CLOCK_S = clock();
	freopen("1.in", "r", stdin);
#endif
	IOS;
	int tc = 1;
//	cin >> tc;
	while(tc--){
		sol();
	}
#ifdef LOCAL
	clock_t CLOCK_E = clock();
	cerr << "Judging Time: " << 1.00 * (CLOCK_E - CLOCK_S) / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

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

input:

3
+-+
-++
+-+
1 1 1
1 -1 3

output:

Yes
111
001
001

result:

ok n=3

Test #2:

score: 0
Accepted
time: 1ms
memory: 5680kb

input:

3
---
-++
+++
-2 -1 0
-2 -1 0

output:

Yes
110
100
000

result:

ok n=3

Test #3:

score: 0
Accepted
time: 1ms
memory: 5844kb

input:

3
+-+
-++
++-
1 0 2
2 2 -1

output:

No

result:

ok n=3

Test #4:

score: 0
Accepted
time: 1ms
memory: 5712kb

input:

1
-
-1
1

output:

No

result:

ok n=1

Test #5:

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

input:

1
-
0
0

output:

Yes
0

result:

ok n=1

Test #6:

score: 0
Accepted
time: 1ms
memory: 5948kb

input:

20
+-------+-----+++-++
-+-++++----++-++-++-
-+++--+---+--+-++---
-+++-+--+----++---+-
+++-+-++++++-+-+---+
-++-----+----++++++-
+-++--+++++-++-+----
+-+----+---+-+++--+-
+++++-+++++----+--+-
------++++---+--++--
++++--------++++--+-
-+-+-++++-+-++-++--+
---+-++---+-++-++---
+-++++-++----+-+++--
+-+...

output:

Yes
11100101100111011001
00101101100110010100
00101011101110111010
10000111011001110111
01101111100101001101
11000010111011100011
01000100000011000101
00100111011101101111
00000000100000010101
11100000101000011001
00000111111111000111
11001010011101001101
00011111001100011001
00110101111001000001
01...

result:

ok n=20

Test #7:

score: 0
Accepted
time: 2ms
memory: 16208kb

input:

100
++++-+-+--++++++-+--+--++-+-+--+++++-+++---+-+-+-++-+-+++-------+-++--+-++--+--+++++-++-+---+--+--++
-++--++-+-++++-+---++-+-+-+-+-+-+-+-+--+-+--+--+++---+--+-----+-----+-++-++-+-++++++--+-+++-+++-++++
--+---++-++--++-+++-------+--+-++------+-----+--+----++++++++-+--+++++--++--+-+-+++---+--+++-+...

output:

Yes
0111010100100011010110001011101111000101100101010111101110001100101100111000100010010010110000010011
1110011010111101000101101110000010001001010110001100010000000110000010110010100111111010111111001111
0000011111100110111000100010111110000000100001001010011110111011000111101010101010101010011001...

result:

ok n=100

Test #8:

score: 0
Accepted
time: 11ms
memory: 38496kb

input:

500
--+-+-+-++-----+++--+-+++-+---+-+-------+++--++++++-+--++--+-+-++++-++++--++--+---++--++----++--+---++-++--+-----+-+---++-++++-+++++++---++-++--+-++++-+----++-+++-+++---+--+++-+--++-++--+++++++-+++--+---+---+-+---++-+-+--+-+++-++-----+++-++-+++-+-++--++++++-+-++-+++---++-+++-++----+--+++----++++...

output:

Yes
01011101011110101001001000011101011111100101100010010101111011100101000011001111110011101101001101111110101011111011101101010110001000111000001101100010111100000110001110110101011011000100100011000111111001100011101001011010100101110100010010001110011000000101011001111001000101111101100001110010...

result:

ok n=500

Test #9:

score: 0
Accepted
time: 643ms
memory: 254256kb

input:

4000
-++-+-+-+--+-++++---+-++------++---+-+++--+++--+++++++---+-++-+++++++----+---+++-++--++---+-++--+----+---+--++-+-+-+-----+-+---++-++--+---+++-++++-+-----++--++-++---++-+--+++-+--+--+-+-++-+++--++---+++-+-+---+++-++-+-++-+-+++---+++---+-+--++---+-+---+--+++--+----+-+--++---+-----+-+--+----+-+++-...

output:

Yes
10000010001011011000110000000101001011010001110101011011110011001111000000010111111001011001110000010000110111000010111100010001100000100001010110010011110010011111000011100010111101011011011010011011000101111011000000110100000011111101000100011101011000100110000101110011011100111101001010000001...

result:

ok n=4000

Test #10:

score: 0
Accepted
time: 664ms
memory: 254264kb

input:

4000
+---+--++-+--++-+-++--+++--++--+++-+-+-+--++++++-++-+-+++-+---++++-+-+++----++-+---++--++--+++-----++---++-+--++++----++--++--+-+-++--+--+++++-+---+++-+++--++++-++-+++++++----+++-----+--++-+++-++-++-+++-+--++++++-+--++--+-+---++--------+-+--++----+-++-+-++---+--++--+-+--+-+++-+--+--++++-++----+...

output:

Yes
10101010110010011000010001100010100001110001010000010000010100000100110001100011011011000111001101100110001101010001011111010010110110001011001010000111101011001100100110011111000101101011001000001111010010000010001100110100010101000011001101111101000101000110110101010010100000100000000101110101...

result:

ok n=4000

Test #11:

score: 0
Accepted
time: 617ms
memory: 254392kb

input:

4000
-+--+------+--+++-++-----++--+-++-++-++-+-+-++++++--++--+-++-+-+++---++-+-+++++-++++++-+-++-++-++-+-++---+-+-------++-+++-++-+-++++-++-+-+-----+----+--+----++++-------++-+--+++----+++++++-+--+-+---+-+++++-+-----++-------++++--+-+-++---++++-++++-++-+++-+-++---+--+---+-++++++--++---+-++++++-+-+--...

output:

Yes
01000000010110011011000000010001011111101010111000001100111001000100011010001110110110100010011100101101111110011011111000111001111101110100001101010111100001110001101101110110001001000000110101110111101001001001001110110000000010001011010010110010010010100100011100100110111101001100111011001000...

result:

ok n=4000

Test #12:

score: 0
Accepted
time: 609ms
memory: 254264kb

input:

4000
+-+-----++++-----++++-+-++-+----+++---++--+---+++-+-++------+-+-++++----+-++++--+-++----+-+---+--+-----+-++--++-+++---+---+++---++-+++---++++---++----+++--+---+---+++-++-+-+-+--+++--++----++-+------+++-++-++--+--+++---+-------++++-+-++--++-+--+------+++++---+---++-++++-+++-++++-+---++-++++----+...

output:

Yes
01011100011011011001010000001011001011101001100110101111101011010001110101100110100010001001110111111100100101010000110111010101000101100000000010111110101011101111011000111111001010010110101110101000110110110010001110011001110001101001100111010101001011101011010100110100000000101010101101010100...

result:

ok n=4000

Test #13:

score: 0
Accepted
time: 611ms
memory: 254172kb

input:

4000
-+++---+-------+-++++-+++-++-+--++----++++++---+---++-++++-+++-++++-+---+--+++-----+-+--++-+--+-++++--+--++-+---+++++++++-+++++++-+++--+-+---++-+-++----+-++--++-++++++++++++++-+++-++-+++-++-++---+---+++-+-+++++++--+-+++-++-+-----+++-++--+++------+++--+++---+--+----++-+--+-+---+--+---+-+-+--++++...

output:

Yes
10101001111001101001001111100101000100100000011101111010110100010110011010111101010010011101001000100101110111111111111010010111011100110001101011111100111001011011111010011000100010011110100100010010110110011010010110010101111001100011110101101101100010001101011100101100101011010010110110100110...

result:

ok n=4000

Test #14:

score: 0
Accepted
time: 652ms
memory: 254252kb

input:

4000
+--+++++--++--+-+++-++-+-+-+-+--++------++++---+++-+-+--+------++-+--++-+-+++-----+-+++++-+------++++-++++-+--+------++--+++++-+-+--+-+++++++++++++++-+--+-+-+---+-+-+++++-++--+-+---++-++--+--+-+++-+-+++++-+--++-+----+++-++-++++-+---+--+-++-++-+-+-+---++-++-+-+----++-++++-----------+++--++++-++-...

output:

Yes
01100000000011010001101010101011101111110000111100101001011111100111100111000101110100000101111110000100001011011111100110100010101101000000000000010001011010111010111100100100101110000101111000001010000010110010111100011010010100110110100100101010111001011010111100100101111111111100011000010011...

result:

ok n=4000

Test #15:

score: 0
Accepted
time: 589ms
memory: 254260kb

input:

4000
---++-++-+-+----++-++++-----------+++--++++-++-++--+-+--+--+-+-++++--++-++--+++++--++--+-+----+-+---++-+++-+--+-++++++++-++---++++-+--+-+++---+-+--+--+-+--+--++++++-+---++++++-++++----+-+-+-++--+---+--+-+++--++++++-+++-+---+--+-----------++-+++--+++++++--++-+++++--+++-+-+++++++++--+---+++--+-+-...

output:

Yes
00011011010100011101111100000000001110011100100110000100100101010110011010000111100110000100001010001101111100101111111101000011110100001110001010010011111100101011011001111110111100101010101000101010010111001110110011110001001000000100101010110001111110011011111011110101111101101010001110010100...

result:

ok n=4000

Test #16:

score: 0
Accepted
time: 640ms
memory: 254240kb

input:

4000
++-+-------+--++-++-++--++-+++++-++++--+-----++-+--+---++++--+-----++++++---+--+---+------+++-+-----+-+++--+++-+-+-+++-----++---+-+---+-+++++-+--+-++--++-+-----++-+-+---+++-+----++++---++--+-+-++-++-+--++---+++------++-+-++++--+--++-++-+++-++-+--++----++---+-+++-+-+++-++-+--++-++++--++-+-+-+-+-...

output:

Yes
10011000000100110011110001111011011110010000011110010001111001000001111110000001000100000010101000001011100111010101110000011000101000101111101001011001101000001101010001110101001111001110010110101101001110011100000011011111100100110110111011010011000001000100110101110110100110110100110101010110...

result:

ok n=4000

Test #17:

score: 0
Accepted
time: 610ms
memory: 254444kb

input:

3999
-+-+++---+-----++-++-+++--++-++-----+-++-+---+++-+++-+-+--+++++-++-+++-+---+-----+-++++-+--++-+++--+-++++--+-+-+-+-+----++----+--+---+--+--++-+++--++-+-++--++------+-+--++++--++-+--+----++---+-+---+++++--++-+-++-+++--++---++++-+-+--+-+++++-+-+--+---+---+-+--++++---+-++++-+--++------+++-+++-+-+-...

output:

Yes
10100010101111100110100011001001011101001011100010001011100000010010001011101111101000010110010001101000011010101010110100011101101110110110010101100101001100111111010110000110010110111100101010111000001100101001000110010100001010110100100101011011101110101100001110100001011001111110001000001010...

result:

ok n=3999

Test #18:

score: 0
Accepted
time: 624ms
memory: 254356kb

input:

3998
--------+++--++-++++--+-+-++---+--++---++-+-++--+----++++---+-++-+-++++++++-+-+++---++++++-+--+-------+--+----++--+--+-+--+++---++-+++---+++-++-+++--++-+----+---+--+-++++--++++-++-+-+---+---+-++----+++++++++++--++--+++++-+++++++-+-+--+-+---+++-++-+++++-+-+-+-+++-+-++-+-+--+-+----+++-+-+--++-+--...

output:

Yes
11111110011000110001110000010110001000110100111101110110000111000100001000101000001010101100001111110001001001011100100000110010101001101011001101110110011110100001100110010111010010100001011111011000100010110001100000001110011001011010111001111011000000010110101001010001000110100000100110000010...

result:

ok n=3998

Test #19:

score: 0
Accepted
time: 219ms
memory: 254192kb

input:

4000
++-+-------+--++-++-++--++-+++++-++++--+-----++-+--+---++++--+-----++++++---+--+---+------+++-+-----+-+++--+++-+-+-+++-----++---+-+---+-+++++-+--+-++--++-+-----++-+-+---+++-+----++++---++--+-+-++-++-+--++---+++------++-+-++++--+--++-++-+++-++-+--++----++---+-+++-+-+++-++-+--++-++++--++-+-+-+-+-...

output:

No

result:

ok n=4000

Test #20:

score: 0
Accepted
time: 246ms
memory: 254432kb

input:

3999
-+-+++---+-----++-++-+++--++-++-----+-++-+---+++-+++-+-+--+++++-++-+++-+---+-----+-++++-+--++-+++--+-++++--+-+-+-+-+----++----+--+---+--+--++-+++--++-+-++--++------+-+--++++--++-+--+----++---+-+---+++++--++-+-++-+++--++---++++-+-+--+-+++++-+-+--+---+---+-+--++++---+-++++-+--++------+++-+++-+-+-...

output:

No

result:

ok n=3999

Test #21:

score: 0
Accepted
time: 216ms
memory: 254172kb

input:

3998
--------+++--++-++++--+-+-++---+--++---++-+-++--+----++++---+-++-+-++++++++-+-+++---++++++-+--+-------+--+----++--+--+-+--+++---++-+++---+++-++-+++--++-+----+---+--+-++++--++++-++-+-+---+---+-++----+++++++++++--++--+++++-+++++++-+-+--+-+---+++-++-+++++-+-+-+-+++-+-++-+-+--+-+----+++-+-+--++-+--...

output:

No

result:

ok n=3998

Test #22:

score: 0
Accepted
time: 1ms
memory: 5716kb

input:

2
+-
--
0 -1
-1 2

output:

No

result:

ok n=2

Test #23:

score: 0
Accepted
time: 1ms
memory: 9820kb

input:

20
--+--------+---++-++
--+++-+----+--++-+++
-+-+-++++---+-+---++
+++-++--++-++-++--++
+---+----+-+++-++++-
----+++++--++----+-+
+-++++----++--++----
++++++-+-+-++-++--+-
-+--+-++++-+-+-+-+-+
--++-+-+--++-++--++-
+---+++-+++-+-+-++-+
+++-+--+++-++-+++-+-
--++--+-++-+--+-+-++
----++-+--+-+-++++-+
--+...

output:

No

result:

ok n=20

Test #24:

score: 0
Accepted
time: 96ms
memory: 254180kb

input:

4000
++---+++-+++-++++++----++-+-+----+-+----+-+-+---+--+-+-----+-+--++++++-++-++++-++----+-++---++++++--+++++--+++--++++-+-+++-++++-+--+++-+++-+--+-+-+++-+-+-+-+++-+-++-++-++++-++-+-++----++++-++++++--+-+---++--+++-++-+-+----+++--+-+--++----+-+++-+-------+++-++--+++-+--+-++----+--------++++--+--+-+...

output:

No

result:

ok n=4000

Test #25:

score: 0
Accepted
time: 643ms
memory: 254284kb

input:

3999
-++--+-+--+++-++--+---++--+---++--+++---++--++---++-+--++---+--++++---+++---++--++-+++++----++-+-+-----++--+++--++--++-+--+-++++-++++--++++-----------+++-+++++++-++--++--+-----++-+-----++++--+++++-+++-+-+--++++-++--++--+--+++-+-+-+-++-++----+---+++++--+++-+---++---+--+-++++-+-++-+-+-+---++-----...

output:

Yes
10011010110001001101110011011100110001110011001110010110011101100001110001110011001000001111001010111110011000110011001011010000100001100001111111111100010000000100110011011111001011111000011000001000101011000010011001101100010101010010011110111000001100010111001110110100001010010101011100111111...

result:

ok n=3999

Test #26:

score: 0
Accepted
time: 608ms
memory: 254232kb

input:

4000
++---+++-+++-++++++----++-+-+----+-+----+-+-+---+--+-+-----+-+--++++++-++-++++-++----+-++---++++++--+++++--+++--++++-+-+++-++++-+--+++-+++-+--+-+-+++-+-+-+-+++-+-++-++-++++-++-+-++----++++-++++++--+-+---++--+++-++-+-+----+++--+-+--++----+-+++-+-------+++-++--+++-+--+-++----+--------++++--+--+-+...

output:

Yes
00111000100010000001111001010111101011110101011101101011111010110000001001000010011110100111000000110000011000110000101000100001011000100010110101000101010100010100100100001001010011110000100000011010111001100010010101111000110101100111101000101111111000100110001011010011110111111110000110110100...

result:

ok n=4000

Test #27:

score: 0
Accepted
time: 579ms
memory: 254276kb

input:

3999
-++--+-+--+++-++--+---++--+---++--+++---++--++---++-+--++---+--++++---+++---++--++-+++++----++-+-+-----++--+++--++--++-+--+-++++-++++--++++-----------+++-+++++++-++--++--+-----++-+-----++++--+++++-+++-+-+--++++-++--++--+--+++-+-+-+-++-++----+---+++++--+++-+---++---+--+-++++-+-++-+-+-+---++-----...

output:

Yes
01100101001110110010001100100011001110001100110001101001100010011110001110001100110111110000110101000001100111001100110100101111011110011110000000000011101111111011001100100000110100000111100111110111010100111101100110010011101010101101100001000111110011101000110001001011110101101010100011000000...

result:

ok n=3999

Test #28:

score: 0
Accepted
time: 590ms
memory: 254304kb

input:

4000
++---+++-+++-++++++----++-+-+----+-+----+-+-+---+--+-+-----+-+--++++++-++-++++-++----+-++---++++++--+++++--+++--++++-+-+++-++++-+--+++-+++-+--+-+-+++-+-+-+-+++-+-++-++-++++-++-+-++----++++-++++++--+-+---++--+++-++-+-+----+++--+-+--++----+-+++-+-------+++-++--+++-+--+-++----+--------++++--+--+-+...

output:

Yes
11000111011101111110000110101000010100001010100010010100000101001111110110111101100001011000111111001111100111001111010111011110100111011101001010111010101011101011011011110110101100001111011111100101000110011101101010000111001010011000010111010000000111011001110100101100001000000001111001001011...

result:

ok n=4000

Extra Test:

score: 0
Extra Test Passed