제출 #144673

#제출 시각아이디문제언어결과실행 시간메모리
144673arayiZagonetka (COI18_zagonetka)C++17
0 / 100
66 ms47376 KiB
#include <iostream> #include <string> #include <queue> #include <stack> #include <algorithm> #include <math.h> #include <vector> #include <cstring> #include <ctime> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <iomanip> #include <ctime> #define fr first #define sc second #define MP make_pair #define PB push_back #define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define lli long long int #define y1 arayikhalatyan using namespace std; lli gcd(lli a, lli b) { if (b == 0) return a; return gcd(b, a % b); } lli cg(lli n) { return n ^ (n >> 1); } lli SUM(lli a) { return (a * (a + 1) / 2); } bool CAN(int x, int y, int n, int m) { if (x >= 0 && y >= 0 && x < n && y < m) { return true; } return false; } double her(double x1, double y1, double x2, double y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } string strsum(string a, string b) { int p = 0; string c; reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); if (b.length() < a.length()) { for (int i = b.length(); i < a.length(); i++) { b += "0"; } } else { for (int i = a.length(); i < b.length(); i++) { a += "0"; } } a += "0", b += "0"; for (int i = 0; i < a.length(); i++) { c += (a[i] - '0' + b[i] - '0' + p) % 10 + '0'; p = (a[i] + b[i] - '0' - '0' + p) / 10; } if (c[c.length() - 1] == '0') c.erase(c.length() - 1, 1); reverse(c.begin(), c.end()); return c; } string strmin(string a, string b) { if (a.length() > b.length()) return b; if (b.length() > a.length()) return a; for (int i = 0; i < a.length(); i++) { if (a[i] > b[i]) return b; if (b[i] > a[i]) return a; } return a; } char vow[] = { 'a', 'e', 'i', 'o', 'u' }; int dx[] = { 1, -1, 0, 0 }; int dy[] = { 0, 0, 1, -1 }; const int N = 1e6 + 30; const lli mod = 998244353; int n; int a[N], b[N], c[N], pos[101]; vector <int> p[N], ch[N]; void tp() { cout << "query "; for (int i = 0; i < n; i++) { cout << a[i] << " "; } cout << endl; } bool dp[101][101]; pair <int, int> s; int get_parent(int x) { if (p[x].size() == 0) return x; return get_parent(p[x][0]); } int get_child(int x) { if (ch[x].size() == 0) return x; return get_child(ch[x][0]); } int main() { fastio; cin >> n; for (int i = 0; i < n; i++) cin >> a[i], b[i] = i + 1, c[i] = n - i, pos[a[i]] = i; int sm; bool flag = false; for (int i = 1; i <= n - 1; i++) { for (int j = 1; j <= n - i; j++) { if (p[pos[j]].size() == 0 && ch[pos[j + i]].size() == 0) { swap(a[pos[j]], a[pos[j + i]]); tp(); cin >> sm; swap(a[pos[j]], a[pos[j + i]]); if (!sm) { p[pos[j]].PB(pos[j + i]); ch[pos[j + i]].PB(pos[j]); } } else if (p[j].size() == 0) { int x = get_child(j + i); swap(a[pos[j]], a[pos[j + i]]); swap(a[x], a[pos[j]]); tp(); cin >> sm; swap(a[pos[j]], a[pos[j + i]]); swap(a[x], a[pos[j]]); if (!sm) { p[pos[j]].PB(pos[j + i]); ch[pos[j + i]].PB(pos[j]); } } else if (ch[j + i].size() == 0) { int x = get_parent(j); swap(a[pos[j]], a[pos[j + i]]); swap(a[x], a[pos[j]]); tp(); cin >> sm; swap(a[pos[j]], a[pos[j + i]]); swap(a[x], a[pos[j]]); if (!sm) { p[pos[j]].PB(pos[j + i]); ch[pos[j + i]].PB(pos[j]); } } else { int x1 = get_parent(j); int x2 = get_child(j + i); if (a[x1] < a[x2]) { swap(a[pos[j]], a[x2]); swap(a[pos[j + i]], a[x1]); tp(); cin >> sm; swap(a[pos[j + i]], a[x1]); swap(a[pos[j]], a[x2]); } else { swap(a[x1], a[x2]); swap(a[pos[j]], a[x2]); swap(a[pos[j + i]], a[x1]); tp(); cin >> sm; swap(a[pos[j]], a[x2]); swap(a[pos[j + i]], a[x1]); swap(a[x1], a[x2]); } if (!sm) { p[pos[j]].PB(pos[j + i]); ch[pos[j + i]].PB(pos[j]); } } } } cout << "end"; cout << endl; for (int i = 0; i < n; i++) { cout << i + 1 << "-"; { for (auto p : ch[i]) cout << p + 1 << " "; } cout << endl; } if (s.sc < s.fr) { b[s.fr] = b[s.sc]; for (int i = s.sc; i < s.fr; i++) b[i]++; } else { c[s.sc] = c[s.fr]; for (int i = s.fr; i < s.sc; i++) c[i]--; } for (int i = 0; i < n; i++) cout << b[i] << " "; cout << endl; for (int i = 0; i < n; i++) cout << c[i] << " "; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

zagonetka.cpp: In function 'std::__cxx11::string strsum(std::__cxx11::string, std::__cxx11::string)':
zagonetka.cpp:57:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = b.length(); i < a.length(); i++)
                            ~~^~~~~~~~~~~~
zagonetka.cpp:64:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = a.length(); i < b.length(); i++)
                            ~~^~~~~~~~~~~~
zagonetka.cpp:71:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < a.length(); i++)
                  ~~^~~~~~~~~~~~
zagonetka.cpp: In function 'std::__cxx11::string strmin(std::__cxx11::string, std::__cxx11::string)':
zagonetka.cpp:84:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < a.length(); i++)
                  ~~^~~~~~~~~~~~
zagonetka.cpp: In function 'int main()':
zagonetka.cpp:130:7: warning: unused variable 'flag' [-Wunused-variable]
  bool flag = false;
       ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...