Submission #702301

# Submission time Handle Problem Language Result Execution time Memory
702301 2023-02-23T13:34:18 Z wcwu Sajam (COCI18_sajam) C++17
90 / 90
287 ms 1388 KB
#include <bits/stdc++.h>
//#include<random>
using namespace std;
/*#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("O3")*/
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")//for codeforces*/
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int, int> pii;
typedef map<ll, ll> mll;
const int MOD1=1e9+7;
const int MOD2=998244353;
const int iINF=INT_MAX;
const ll INF=LLONG_MAX;
const ld PI=3.14159265358979323846;
ll gcd(ll a,ll b){if(b==0) return a; return gcd(b,a%b);}
ll fpow(ll a,ll b,ll m) {
    if(!b) return 1;
    ll ans=fpow(a*a%m,b/2,m);
    return (b%2?ans*a%m:ans);
}
ll inv(ll a,ll m) {return fpow(a,m-2,m);}
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define dbg(n) cerr<<#n<<": "<<n<<"\n";
#define optline cout<<"\n";
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define irep(i,m,n) for(ll i=m;i>=n;i--)
#define F first
#define S second
#define All(c) c.begin(), c.end()
#define pb push_back
#define eb emplace_back
//#define mp make_pair
#define uni(c) c.resize(distance(c.begin(), unique(c.begin(), c.end())))
#define unisort(c) sort(c.begin(), c.end());uni(c)

bitset<1000> bs[1000];
ll n;
ll xorr(bitset<1000> x, bitset<1000> y) {return min((int)(x^y).count(), (int)(n-(x^y).count())); }
ll calc(ll x) {
    ll ret=0;
    rep(i, n) ret+=xorr(bs[i], bs[x]);
    return ret;
}
signed main() {
    ll k;
    cin>>n>>k;
    ll ans=INF;
    rep(i, n) {
        string s;
        cin>>s;
        rep(j, s.size()) {
            if(s[j]=='x') bs[i][j]=1;
            else bs[i][j]=0;
        }
    }
    rep(i, n) ans=min(calc(i), ans);
    if(k==n) {
        rep(i, n) {
            bs[0][i].flip();
            ans=min(ans, 1+calc(0));
            bs[0][i].flip();
        }
    }
    if(ans<=k) cout<<"DA\n";
    else cout<<"NE\n";
}

Compilation message

sajam.cpp: In function 'int main()':
sajam.cpp:30:30: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 | #define rep(i,n) for(ll i=0;i<n;i++)
......
   57 |         rep(j, s.size()) {
      |             ~~~~~~~~~~~       
sajam.cpp:57:9: note: in expansion of macro 'rep'
   57 |         rep(j, s.size()) {
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 31 ms 468 KB Output is correct
3 Correct 43 ms 596 KB Output is correct
4 Correct 133 ms 1204 KB Output is correct
5 Correct 44 ms 596 KB Output is correct
6 Correct 18 ms 320 KB Output is correct
7 Correct 41 ms 596 KB Output is correct
8 Correct 140 ms 1264 KB Output is correct
9 Correct 8 ms 340 KB Output is correct
10 Correct 142 ms 1180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 308 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 3 ms 212 KB Output is correct
6 Correct 2 ms 308 KB Output is correct
7 Correct 3 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 3 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 928 KB Output is correct
2 Correct 116 ms 1068 KB Output is correct
3 Correct 75 ms 824 KB Output is correct
4 Correct 67 ms 756 KB Output is correct
5 Correct 157 ms 1192 KB Output is correct
6 Correct 49 ms 568 KB Output is correct
7 Correct 90 ms 912 KB Output is correct
8 Correct 100 ms 976 KB Output is correct
9 Correct 27 ms 416 KB Output is correct
10 Correct 162 ms 1320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 121 ms 1108 KB Output is correct
2 Correct 119 ms 1108 KB Output is correct
3 Correct 70 ms 724 KB Output is correct
4 Correct 91 ms 900 KB Output is correct
5 Correct 93 ms 944 KB Output is correct
6 Correct 151 ms 1356 KB Output is correct
7 Correct 37 ms 568 KB Output is correct
8 Correct 84 ms 872 KB Output is correct
9 Correct 93 ms 940 KB Output is correct
10 Correct 158 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 119 ms 724 KB Output is correct
2 Correct 121 ms 780 KB Output is correct
3 Correct 272 ms 1352 KB Output is correct
4 Correct 87 ms 648 KB Output is correct
5 Correct 126 ms 784 KB Output is correct
6 Correct 279 ms 1324 KB Output is correct
7 Correct 95 ms 596 KB Output is correct
8 Correct 90 ms 596 KB Output is correct
9 Correct 93 ms 680 KB Output is correct
10 Correct 89 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 287 ms 1388 KB Output is correct
2 Correct 268 ms 1336 KB Output is correct
3 Correct 250 ms 1256 KB Output is correct
4 Correct 170 ms 892 KB Output is correct
5 Correct 155 ms 840 KB Output is correct
6 Correct 176 ms 840 KB Output is correct
7 Correct 86 ms 648 KB Output is correct
8 Correct 243 ms 1144 KB Output is correct
9 Correct 132 ms 760 KB Output is correct
10 Correct 271 ms 1304 KB Output is correct