Submission #1080463

#TimeUsernameProblemLanguageResultExecution timeMemory
1080463thelegendary08Dragon 2 (JOI17_dragon2)C++14
0 / 100
3686 ms1044 KiB
#include<bits/stdc++.h> #define pb push_back #define int long long #define vi vector<double> #define vvi vector<vector<int>> #define vll vector<long long int> #define vvll vector<vector<long long int>> #define pii pair<double, double> #define vpii vector<pair<double, double>> #define vc vector<char> #define vvc vector<vector<char>> #define vb vector<bool> #define mii map<int,int> #define mll map<long long int, long long int> #define mivi map<int,vector<int>> #define f0r(i,n) for(int i=0;i<n;i++) #define FOR(i,k,n) for(int i=k;i<n;i++) using namespace std; pii line(pii a, pii b){ return {(b.second - a.second) / (b.first - a.first), a.second - a.first * ((b.second - a.second) / (b.first - a.first))}; } pii intersect(pii a, pii b){ int x = (b.second - a.second)/(a.first - b.first); return {x, a.first * x + a.second}; } signed main(){ ios::sync_with_stdio(false); cin.tie(NULL); //ifstream cin(".in"); //ofstream cout(".out"); int n,m; cin>>n>>m; vpii tribe[m+1]; f0r(i, n){ double a,b; int c; cin>>a>>b>>c; tribe[c].pb({a,b}); } double x1, y1, x2, y2; cin>>x1>>y1>>x2>>y2; pii mainline = line({x1,y1}, {x2,y2}); int ub = max(y1, y2); int lb = min(y1, y2); int q; cin>>q; while(q--){ int a,b; cin>>a>>b; int ans = 0; f0r(i, tribe[a].size()){ f0r(j, tribe[b].size()){ pii attacker = tribe[a][i]; pii victim = tribe[b][j]; pii l = line(attacker, victim); //cout<<l.first<<' '<<l.second<<' '<<mainline.first<<' '<<mainline.second<<'\n'; pii kousaten = intersect(l, mainline); //cout<<kousaten.first<<' '<<kousaten.second<<'\n'; bool ok = 1; if(l.first == mainline.first)ok = 0; if(attacker.second > victim.second && kousaten.second > attacker.second){ ok = 0; } if(attacker.second < victim.second && kousaten.second < attacker.second){ ok = 0; } if(attacker.second == victim.second && (kousaten.first > max(attacker.first, victim.first)|| kousaten.first < min(attacker.first, victim.first)))ok = 0; if(kousaten.second > ub || kousaten.second < lb)ok = 0; if(ok)ans++; } } cout<<ans<<'\n'; } }

Compilation message (stderr)

dragon2.cpp: In function 'int main()':
dragon2.cpp:16:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 | #define f0r(i,n) for(int i=0;i<n;i++)
......
   54 |   f0r(i, tribe[a].size()){
      |       ~~~~~~~~~~~~~~~~~~       
dragon2.cpp:54:3: note: in expansion of macro 'f0r'
   54 |   f0r(i, tribe[a].size()){
      |   ^~~
dragon2.cpp:16:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 | #define f0r(i,n) for(int i=0;i<n;i++)
......
   55 |    f0r(j, tribe[b].size()){
      |        ~~~~~~~~~~~~~~~~~~      
dragon2.cpp:55:4: note: in expansion of macro 'f0r'
   55 |    f0r(j, tribe[b].size()){
      |    ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...