제출 #878402

#제출 시각아이디문제언어결과실행 시간메모리
878402princeSimple game (IZhO17_game)C++17
22 / 100
1059 ms2020 KiB
#include "bits/stdc++.h" using namespace std; using ll = long long; void solve(){ int N, M; cin >> N >> M; vector<pair<int, int>> chain(N); for (int i = 0; i < N; ++i) { cin >> chain[i].second; chain[i].first = i + 1; } vector<int> output; for (int i = 0; i < M; ++i) { int type; cin >> type; if (type == 1) { int pos, val; cin >> pos >> val; chain[pos - 1].second = val; } else if (type == 2) { int h; cin >> h; int intersections = 0; for (int i = 0; i < chain.size() - 1; ++i) { if (min(chain[i].second, chain[i + 1].second) <= h && h <= max(chain[i].second, chain[i + 1].second)) { intersections++; } } output.push_back(intersections); } } for (int ans : output) { cout << ans << endl; } } int main() { cin.tie(0)->sync_with_stdio(false); #ifdef prince freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int q = 1; // cin >> q; while (q--) { solve(); cout << '\n'; } }

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

game.cpp: In function 'void solve()':
game.cpp:30:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             for (int i = 0; i < chain.size() - 1; ++i) {
      |                             ~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...