Submission #1139752

#TimeUsernameProblemLanguageResultExecution timeMemory
1139752KerimPermutation Recovery (info1cup17_permutation)C++20
0 / 100
1095 ms2880 KiB
#include "bits/stdc++.h" using namespace std; vector<int>mods{(int) 1e9 + 7, 998244353}; struct Int { vector<int> val; Int(string s = "") { for (auto& mod : mods) { int ans = 0; for (auto& c : s) { ans = (ans * 10ll + c - '0') % mod; } val.push_back(ans); } } Int& operator+=(const Int& other) { for (int i = 0; i < (int) mods.size(); i++) { val[i] += other.val[i]; if (val[i] >= mods[i]) { val[i] -= mods[i]; } } return *this; } Int& operator-=(const Int& other) { for (int i = 0; i < (int) mods.size(); i++) { val[i] -= other.val[i]; if (val[i] < 0) { val[i] += mods[i]; } } return *this; } bool operator==(const Int& other) const { return val == other.val; } }; const int N = 7e4+4; int P[N], A[N]; int main(){ // freopen("file.in", "r", stdin); int n; scanf("%d", &n); vector<Int> Q(n); for (int i = 0; i < n; i++){ string s; cin >> s; Q[i] = Int(s); } for (int i = n-1; i > 0; i--) Q[i] -= Q[i-1]; vector<int> A; for (int i = 0; i < n; i++){ Int cur("1"); for (int j = 0; j <= (int)A.size(); j++){ if (cur == Q[i]){ A.insert(A.begin()+j, i); break; } cur += Q[A[j]]; } A.push_back(i); } for (int i = 0; i < n; i++) P[A[i]] = i + 1; for (int i = 0; i < n; i++) printf("%d ", P[i]); puts(""); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:50:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...