Submission #1177401

#TimeUsernameProblemLanguageResultExecution timeMemory
1177401Kaztaev_AlisherHieroglyphs (IOI24_hieroglyphs)C++20
3 / 100
19 ms3396 KiB
#include <bits/stdc++.h> #define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout) #define all(a) a.begin() , a.end() #define F first #define S second using namespace std; using ll = long long; const ll N = 2e5+5 , inf = 2e9 + 7; const ll INF = 1e18 , mod = 1e9+7; int a[N] , b[N]; vector<int> ucs(vector<int> A, vector<int> B) { int n = A.size() , lastA = -1 , lastB = -1; vector<int> vec; for(int i = 0; i < n; i++) a[i] = b[i] = -1; for(int i = 0; i < n; i++){ if(A[i] == B[i]){ vec.push_back(A[i]); continue; } a[A[i]] = i; b[B[i]] = i; if(b[A[i]] > lastB && a[B[i]] > lastA){ return vector<int>({-1}); } if(b[A[i]] > lastB) vec.push_back(A[i]) , lastA = i; if(a[B[i]] > lastA) vec.push_back(B[i]) , lastB = i; } return vec; } // int main() { // int N, M; // assert(2 == scanf("%d%d", &N, &M)); // std::vector<int> A(N), B(M); // for (int i = 0; i < N; i++) // assert(1 == scanf("%d", &A[i])); // for (int j = 0; j < M; j++) // assert(1 == scanf("%d", &B[j])); // fclose(stdin); // // std::vector<int> R = ucs(A, B); // // int T = (int)R.size(); // printf("%d\n", T); // for (int i = 0; i < T; i++) // printf("%s%d", (i == 0 ? "" : " "), R[i]); // printf("\n"); // fclose(stdout); // // return 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...