# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
508833 |
2022-01-13T21:22:14 Z |
inksamurai |
Sajam (COCI18_sajam) |
C++17 |
|
559 ms |
19916 KB |
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _34raRxL ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
void print(){
cout<<"\n";
}
template<class te,class ...ti>
void print(const te&v, const ti&...nv) {
cout<<v;
if(sizeof...(nv)){
cout<<" ";
print(nv...);
}
}
#define yare {cout<<"DA\n"; exit(0);}
#define nare {cout<<"NE\n"; exit(0);}
using pii=pair<int,int>;
using vi=vector<int>;
using vll=vector<long long>;
signed main(){
_34raRxL;
int n,k;
cin>>n>>k;
// assert(k<=n/2);
int h=n,w=n;
vec(vi) a(h,vi(w));
rep(i,h){
string s;
cin>>s;
rep(j,w){
a[i][j]=s[j]=='o';
}
}
vec(vi) tbl(2*n,vi(2*n));
rep(i,h){
rep(j,w){
int x=a[i][j];
// co = j + n ..
int ro=i,co=j+n;
tbl[ro][co]=tbl[co][ro]=x;
}
}
vi c(n);
{
rep(i,n){
rep(j,n){
c[i]+=(tbl[i][j+n]!=tbl[0][j+n]);
}
}
}
auto affine=[&](int i0,int i1,int add)->void{
rep(i,n){
if(i==i0 or i==i1) continue;
add+=min(c[i],n-c[i]);
}
if(add<=k){
yare;
}
};
affine(-1,-1,0);
// rep(i,n){
// affine(i,-1,max(c[i],n-c[i]));
// }
rep(i,n){
crep(j,i+1,n){
if(i==j) continue;
assert(max(c[i],n-c[i])+max(c[j],n-c[j])>=n);
affine(i,j,max(c[i],n-c[i])+max(c[j],n-c[j]));
}
}
nare;
//
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
4 ms |
3788 KB |
Output is correct |
3 |
Correct |
5 ms |
5536 KB |
Output is correct |
4 |
Correct |
20 ms |
16588 KB |
Output is correct |
5 |
Correct |
5 ms |
5580 KB |
Output is correct |
6 |
Correct |
2 ms |
2380 KB |
Output is correct |
7 |
Correct |
67 ms |
5196 KB |
Output is correct |
8 |
Correct |
425 ms |
17304 KB |
Output is correct |
9 |
Correct |
8 ms |
1228 KB |
Output is correct |
10 |
Correct |
448 ms |
17612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Incorrect |
1 ms |
460 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
11416 KB |
Output is correct |
2 |
Correct |
12 ms |
13948 KB |
Output is correct |
3 |
Correct |
11 ms |
9420 KB |
Output is correct |
4 |
Correct |
8 ms |
8328 KB |
Output is correct |
5 |
Correct |
15 ms |
16204 KB |
Output is correct |
6 |
Correct |
92 ms |
5964 KB |
Output is correct |
7 |
Correct |
238 ms |
11144 KB |
Output is correct |
8 |
Correct |
295 ms |
12136 KB |
Output is correct |
9 |
Correct |
37 ms |
3404 KB |
Output is correct |
10 |
Correct |
501 ms |
19520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
15052 KB |
Output is correct |
2 |
Correct |
15 ms |
14668 KB |
Output is correct |
3 |
Correct |
8 ms |
8524 KB |
Output is correct |
4 |
Correct |
10 ms |
10956 KB |
Output is correct |
5 |
Correct |
11 ms |
11676 KB |
Output is correct |
6 |
Correct |
476 ms |
18712 KB |
Output is correct |
7 |
Correct |
77 ms |
4772 KB |
Output is correct |
8 |
Correct |
224 ms |
10552 KB |
Output is correct |
9 |
Correct |
234 ms |
11596 KB |
Output is correct |
10 |
Correct |
559 ms |
19572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
8524 KB |
Output is correct |
2 |
Correct |
7 ms |
8652 KB |
Output is correct |
3 |
Incorrect |
514 ms |
19384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
19916 KB |
Output is correct |
2 |
Correct |
17 ms |
18892 KB |
Output is correct |
3 |
Incorrect |
435 ms |
17436 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |