# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
164221 | 2019-11-18T16:48:25 Z | aggu_01000101 | Ispit (COCI19_ispit) | C++14 | 160 ms | 51568 KB |
#include <iostream> #include <cmath> #include <vector> #include <algorithm> #include <queue> #include <fstream> #include <set> #include <iomanip> #include <unordered_map> #define INF 1e16 #define int long long #define N (int)1e5 + 5 using namespace std; int32_t main(){ ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0); int n, m; cin>>n>>m; char mat[n][n]; for(int i = 0;i<n;i++){ string s; cin>>s; for(int j =0 ;j<s.length();j++){ mat[i][j] = s[j]; } } int freq[n][n][26]; for(int i = 0;i<n;i++){ for(int j =0 ;j<n;j++){ for(int k = 0;k<26;k++){ freq[i][j][k] = 0; } } } for(int i = 0;i<n;i++){ freq[i][0][mat[i][0] - 'a']=1; for(int j = 1;j<n;j++){ for(int k = 0;k<26;k++){ freq[i][j][k]=freq[i][j-1][k]; } freq[i][j][mat[i][j]-'a']++; } } bool possible = false; for(int i = 0;i<=(n-m);i++){ int last = i+m-1; for(int j = 0;j<(n-1);j++){ bool firstsame = true; bool lastsame = true; bool charcountsame = true; for(int k = 0;k<i;k++){ if(mat[j][k]!=mat[j+1][k]) firstsame = false; } for(int k = last+1;k<n;k++){ if(mat[j][k]!=mat[j+1][k]) lastsame = false; } for(int k = 0;k<26;k++){ int count1 = freq[j][last][k] - i==0?0:freq[j][i-1][k]; int count2 = freq[j+1][last][k] - i==0?0:freq[j+1][i-1][k]; if(count1!=count2) charcountsame = false; } if(firstsame&&lastsame&&charcountsame) possible = true; } } for(int i = 0;i<(n-1);i++){ bool same = true; for(int j = 0;j<n;j++){ if(mat[i][j]!=mat[i+1][j]) same = false; } if(same) possible = true; } if(possible) cout<<"DA"<<endl; else cout<<"NE"<<endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 8440 KB | Output is correct |
2 | Incorrect | 10 ms | 8440 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 8440 KB | Output is correct |
2 | Incorrect | 11 ms | 8568 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 8440 KB | Output is correct |
2 | Correct | 10 ms | 8440 KB | Output is correct |
3 | Correct | 12 ms | 8440 KB | Output is correct |
4 | Incorrect | 11 ms | 8444 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 8440 KB | Output is correct |
2 | Incorrect | 10 ms | 8568 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 59 ms | 51500 KB | Output is correct |
2 | Incorrect | 55 ms | 51424 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 54 ms | 51404 KB | Output is correct |
2 | Correct | 57 ms | 51448 KB | Output is correct |
3 | Correct | 155 ms | 51540 KB | Output is correct |
4 | Incorrect | 160 ms | 51568 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 54 ms | 51484 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |