제출 #1068351

#제출 시각아이디문제언어결과실행 시간메모리
1068351faricaNaval battle (CEOI24_battle)C++14
6 / 100
2374 ms1048576 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int collision(int x1, int y1, char c1, int x2, int y2, char c2) { if(c1 == c2) return -1; if((c2 == 'N' && c1 == 'S') or (c2 == 'W' && c1 == 'E')) { swap(x1, x2); swap(y1, y2); swap(c1, c2); } if(c1 == 'N' && c2 == 'S') { if(x1 != x2 or y1 < y2) return -1; return y1 - y2; } if(c1 == 'W' && c2 == 'E') { if(y1 != y2 or x1 < x2) return -1; return x1 - x2; } int X = abs(x1 - x2), Y = abs(y1 - y2); if(X != Y) return -1; if(c1 == 'E' or c1 == 'W') { swap(x1, x2); swap(y1, y2); swap(c1, c2); } if(c1 == 'N' && (y1 - Y) != y2) return -1; else if(c1 == 'S' && (y1 + Y) != y2) return -1; if(c2 == 'W' && (x2 - X) != x1) return -1; else if(c2 == 'E' && (x2 + X) != x1) return -1; return X; } bool cmp(pair<int,pair<int,int>>x, pair<int,pair<int,int>>y) { return x.first < y.first; } void solve() { int n; cin >> n; int x[n], y[n]; char c[n]; for(int i=0; i<n; ++i) { cin >> x[i] >> y[i] >> c[i]; } vector<pair<int,pair<int,int>>>v; for(int i=0; i<n; ++i) { for(int j = i+1; j<n; ++j) { int X = collision(x[i], y[i], c[i], x[j], y[j], c[j]); if(X != -1) v.push_back({X, {i, j}}); } } sort(v.begin(), v.end(), cmp); vector<int>taken(n, -1); for(int i=0; i<v.size(); ++i) { int first = v[i].second.first, second = v[i].second.second; if((taken[first] == v[i].first or taken[first] == -1) && (taken[second] == v[i].first or taken[second] == -1)) { taken[first] = v[i].first; taken[second] = v[i].first; } } for(int i=0; i<n; ++i) { if(taken[i] == -1) cout << i+1 << endl; } } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; while(t--) solve(); return 0; }

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

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