Submission #97279

# Submission time Handle Problem Language Result Execution time Memory
97279 2019-02-14T18:04:00 Z hjc20032003 Sajam (COCI18_sajam) C++14
90 / 90
998 ms 2312 KB
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define GN(x,y) x=min(x,y)
#define REP(i,s,t) for(int i=s;i<=t;i++)
using namespace std;
int n,ans=inf;
bool m[1005][1005];
int cal(int a,int b) {
	int ret=0;
	REP(i,1,n) if(m[a][i]!=m[b][i]) ret++;
	return min(ret,n-ret);
}
bool judge() {
	REP(i,2,n) if(cal(1,i)>1) return false;
	return true;
}
int main() {
	int k; cin>>n>>k;
	REP(i,1,n) REP(j,1,n) {
		char ch; cin>>ch;
		if(ch=='o') m[i][j]=true;
	}
	REP(i,1,n) {
		int cnt=0;
		REP(j,1,n) cnt+=cal(i,j);
		GN(ans,cnt);
		if(ans<=k) {cout<<"DA"; return 0;}
	}
	if(k<n) {cout<<"NE"; return 0;}
	REP(i,1,n) {
		m[1][i]=!m[1][i];
		if(judge()) {cout<<"DA"; return 0;}
		m[1][i]=!m[1][i];
	}
	cout<<"NE"; return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 17 ms 888 KB Output is correct
3 Correct 28 ms 1144 KB Output is correct
4 Correct 64 ms 2040 KB Output is correct
5 Correct 22 ms 1144 KB Output is correct
6 Correct 10 ms 768 KB Output is correct
7 Correct 160 ms 1124 KB Output is correct
8 Correct 958 ms 2076 KB Output is correct
9 Correct 21 ms 640 KB Output is correct
10 Correct 863 ms 2168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 4 ms 412 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 1656 KB Output is correct
2 Correct 49 ms 1656 KB Output is correct
3 Correct 42 ms 1400 KB Output is correct
4 Correct 29 ms 1400 KB Output is correct
5 Correct 57 ms 2040 KB Output is correct
6 Correct 169 ms 1152 KB Output is correct
7 Correct 417 ms 1656 KB Output is correct
8 Correct 478 ms 1784 KB Output is correct
9 Correct 78 ms 1040 KB Output is correct
10 Correct 998 ms 2312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 2068 KB Output is correct
2 Correct 52 ms 2040 KB Output is correct
3 Correct 30 ms 1408 KB Output is correct
4 Correct 37 ms 1656 KB Output is correct
5 Correct 39 ms 1656 KB Output is correct
6 Correct 945 ms 2240 KB Output is correct
7 Correct 131 ms 1024 KB Output is correct
8 Correct 406 ms 1592 KB Output is correct
9 Correct 521 ms 1744 KB Output is correct
10 Correct 971 ms 2296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 1400 KB Output is correct
2 Correct 35 ms 1388 KB Output is correct
3 Correct 985 ms 2288 KB Output is correct
4 Correct 175 ms 1152 KB Output is correct
5 Correct 287 ms 1528 KB Output is correct
6 Correct 937 ms 2296 KB Output is correct
7 Correct 159 ms 1272 KB Output is correct
8 Correct 205 ms 1248 KB Output is correct
9 Correct 290 ms 1272 KB Output is correct
10 Correct 208 ms 1176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 2284 KB Output is correct
2 Correct 61 ms 2220 KB Output is correct
3 Correct 843 ms 2148 KB Output is correct
4 Correct 414 ms 1656 KB Output is correct
5 Correct 431 ms 1784 KB Output is correct
6 Correct 544 ms 1764 KB Output is correct
7 Correct 242 ms 1244 KB Output is correct
8 Correct 665 ms 2040 KB Output is correct
9 Correct 277 ms 1404 KB Output is correct
10 Correct 874 ms 2228 KB Output is correct