Submission #102456

# Submission time Handle Problem Language Result Execution time Memory
102456 2019-03-25T06:29:02 Z BanFcc Sajam (COCI18_sajam) C++14
90 / 90
85 ms 5376 KB
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define debug(x) cerr<<#x<<" = "<<(x)<<endl
#define eps 1e-8
#define pi acos(-1.0)
using namespace std;
void test(){cerr<<"\n";}
template<typename T,typename... Args>void test(T x,Args... args){cerr<<x<<" ";test(args...);}
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAXN=(int)1e5+5;
const int MOD=(int)1e9+7;
char str[1005];
bitset<1005>b[1005];
int a[1005][1005];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%s",str);
        for(int j=0;j<n;j++){
            b[i][j]=(str[j]=='o');
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            a[i][j]=a[j][i]=n-(b[i]^b[j]).count();
        }
    }
    int flag=0;
    for(int i=1;i<=n;i++){
        int stp=0;
        for(int j=1;j<=n;j++){
            if(i==j)continue;
            stp+=min(n-a[i][j],a[i][j]);
        }
        if(stp<=k){
            flag=1;
            break;
        }
    }
    if(k==n&&flag==0){
        for(int i=0;i<n;i++){
            int f=1;
            for(int j=2;j<=n;j++){
                int tmp=a[1][j];
                if(b[1][i]!=b[j][i])tmp++;
                else tmp--;
                if(tmp!=1&&tmp!=n-1)f=0;
            }
            if(f){
                flag=1;
                break;
            }
        }

    }
    if(flag)printf("DA\n");
    else printf("NE\n");
    return 0;
}

Compilation message

sajam.cpp: In function 'int main()':
sajam.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&k);
     ~~~~~^~~~~~~~~~~~~~
sajam.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s",str);
         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 17 ms 2304 KB Output is correct
3 Correct 16 ms 2688 KB Output is correct
4 Correct 44 ms 4864 KB Output is correct
5 Correct 16 ms 2688 KB Output is correct
6 Correct 7 ms 1792 KB Output is correct
7 Correct 23 ms 2560 KB Output is correct
8 Correct 57 ms 4992 KB Output is correct
9 Correct 6 ms 1280 KB Output is correct
10 Correct 52 ms 4992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 3 ms 640 KB Output is correct
3 Correct 3 ms 640 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 2 ms 640 KB Output is correct
9 Correct 3 ms 640 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 3976 KB Output is correct
2 Correct 59 ms 4472 KB Output is correct
3 Correct 27 ms 3584 KB Output is correct
4 Correct 32 ms 3328 KB Output is correct
5 Correct 46 ms 4984 KB Output is correct
6 Correct 24 ms 2816 KB Output is correct
7 Correct 36 ms 3968 KB Output is correct
8 Correct 50 ms 4096 KB Output is correct
9 Correct 14 ms 2176 KB Output is correct
10 Correct 56 ms 5376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 4608 KB Output is correct
2 Correct 41 ms 4608 KB Output is correct
3 Correct 25 ms 3456 KB Output is correct
4 Correct 35 ms 3848 KB Output is correct
5 Correct 31 ms 3968 KB Output is correct
6 Correct 82 ms 5224 KB Output is correct
7 Correct 14 ms 2432 KB Output is correct
8 Correct 36 ms 3832 KB Output is correct
9 Correct 33 ms 3968 KB Output is correct
10 Correct 78 ms 5376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 3468 KB Output is correct
2 Correct 24 ms 3444 KB Output is correct
3 Correct 70 ms 5260 KB Output is correct
4 Correct 22 ms 2816 KB Output is correct
5 Correct 28 ms 3456 KB Output is correct
6 Correct 47 ms 5240 KB Output is correct
7 Correct 17 ms 2804 KB Output is correct
8 Correct 20 ms 2944 KB Output is correct
9 Correct 21 ms 3072 KB Output is correct
10 Correct 20 ms 2968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 5376 KB Output is correct
2 Correct 47 ms 5248 KB Output is correct
3 Correct 47 ms 4992 KB Output is correct
4 Correct 32 ms 3840 KB Output is correct
5 Correct 31 ms 3840 KB Output is correct
6 Correct 33 ms 4088 KB Output is correct
7 Correct 18 ms 2816 KB Output is correct
8 Correct 46 ms 4608 KB Output is correct
9 Correct 25 ms 3328 KB Output is correct
10 Correct 85 ms 5120 KB Output is correct