# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
776838 |
2023-07-08T10:12:19 Z |
vjudge1 |
Sajam (COCI18_sajam) |
C++17 |
|
852 ms |
5332 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
#define fi first
#define se second
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo inf = 1000000000;
const lo li = 1005;
const lo mod = 1000000007;
int n,m,a[li][li],k,flag,t,acik[li],tut[li];
int cev;
string s[li];
vector<int> v;
int main(void){
fio();
cin>>n>>k;
FOR cin>>s[i];
//~ if(k>(n+1)/2){cout<<"DA\n";return 0;}
FOR{
for(int j=0;j<n;j++){
if(s[i][j]=='o')a[i][j]=1;
}
}
int mn=0;
for(int ii=1;ii<=n;ii++){
cev=0;
for(int i=1;i<=n;i++){
if(i==ii)continue;
int say=0;
for(int j=0;j<n;j++){
if((a[ii][j]^a[i][j]))say++;
}
tut[i]=say;
cev+=min(say,n-say);
//~ cout<<i<<" ()() "<<cev<<endl;
}
if(ii==1)mn=cev;
else mn=min(mn,cev);
//~ for(int j=0;j<n;j++){
//~ for(int i=)
//~ }
}
if(mn>k){cout<<"NE\n";return 0;}
cout<<"DA\n";
return 0;
cev=k+1;
FOR{
v.clear();
for(int j=0;j<n;j++){
if(s[i][j]=='o')v.pb(acik[j]);
else v.pb(n-acik[j]);
}
sort(v.begin(),v.end());
if(n%2){
int cur=0;
for(auto go:v)cur+=abs(go-v[n/2]);
//~ cout<<cur<<" AAA "<<cev<<endl;
cev=min(cev,cur);
}
else{
int cur=0;
for(auto go:v)cur+=abs(go-v[n/2]);
//~ cout<<cur<<" BBB "<<cev<<endl;
cev=min(cev,cur);
cur=0;
for(auto go:v)cur+=abs(go-v[n/2-1]);
//~ cout<<cur<<" CCC "<<cev<<endl;
cev=min(cev,cur);
}
}
if(cev>k)cout<<"NE\n";
else cout<<"DA\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
67 ms |
2188 KB |
Output is correct |
3 |
Correct |
118 ms |
2644 KB |
Output is correct |
4 |
Correct |
640 ms |
4788 KB |
Output is correct |
5 |
Correct |
126 ms |
2644 KB |
Output is correct |
6 |
Correct |
31 ms |
1736 KB |
Output is correct |
7 |
Correct |
109 ms |
2516 KB |
Output is correct |
8 |
Correct |
683 ms |
4820 KB |
Output is correct |
9 |
Correct |
11 ms |
1236 KB |
Output is correct |
10 |
Correct |
735 ms |
4960 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
374 ms |
3884 KB |
Output is correct |
2 |
Correct |
488 ms |
4344 KB |
Output is correct |
3 |
Correct |
283 ms |
3496 KB |
Output is correct |
4 |
Correct |
223 ms |
3156 KB |
Output is correct |
5 |
Correct |
626 ms |
4748 KB |
Output is correct |
6 |
Correct |
138 ms |
2772 KB |
Output is correct |
7 |
Correct |
389 ms |
3796 KB |
Output is correct |
8 |
Correct |
400 ms |
4012 KB |
Output is correct |
9 |
Correct |
59 ms |
2088 KB |
Output is correct |
10 |
Correct |
834 ms |
5268 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
559 ms |
4544 KB |
Output is correct |
2 |
Correct |
574 ms |
4488 KB |
Output is correct |
3 |
Correct |
233 ms |
3316 KB |
Output is correct |
4 |
Correct |
358 ms |
3796 KB |
Output is correct |
5 |
Correct |
371 ms |
3924 KB |
Output is correct |
6 |
Correct |
763 ms |
5116 KB |
Output is correct |
7 |
Correct |
94 ms |
2448 KB |
Output is correct |
8 |
Correct |
322 ms |
3724 KB |
Output is correct |
9 |
Correct |
377 ms |
3924 KB |
Output is correct |
10 |
Correct |
827 ms |
5232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
239 ms |
3336 KB |
Output is correct |
2 |
Correct |
236 ms |
3356 KB |
Output is correct |
3 |
Incorrect |
799 ms |
5232 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
852 ms |
5332 KB |
Output is correct |
2 |
Correct |
808 ms |
5168 KB |
Output is correct |
3 |
Incorrect |
697 ms |
4820 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |