Submission #651344

#TimeUsernameProblemLanguageResultExecution timeMemory
651344fatemetmhrGenetics (BOI18_genetics)C++17
47 / 100
185 ms82676 KiB
// ~ Be Name Khoda ~ // Harf ke nazanim... // Zende bemoonim? // Ya oonm na? #include<bits/stdc++.h> using namespace std; typedef long long ll; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define fi first #define se second const int maxn = 1e6 + 10; const int maxn5 = 5e5 + 10; const int maxnt = 1.2e6 + 10; const int maxn3 = 4102; const int mod = 1e9 + 7; const ll inf = 1e18; int a[maxn3][maxn3]; ll sum[maxn3], w[maxn3]; int main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n, m, k; cin >> n >> m >> k; ll sumw = 0; for(int i = 0; i < n; i++){ string s; cin >> s; w[i] = rng() % mod + 1; sumw += w[i]; for(int j = 0; j < m; j++){ a[i][j] = (s[j] == 'A' ? 1 : -1); sum[j] += w[i] * a[i][j]; } } for(int i = 0; i < n; i++){ ll ans = 0; for(int j = 0; j < m; j++) ans += (sum[j] - w[i] * a[i][j]) * a[i][j]; if(ans == (sumw - w[i]) * (m - 2 * k)) return cout << i + 1 << endl, 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...