Submission #339046

# Submission time Handle Problem Language Result Execution time Memory
339046 2020-12-24T13:15:19 Z beksultan04 Ants (IZhO12_ants) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
const int N = 1e6+12,INF=1e9+7;
int dp[200][200],w[N];
deque <pair<pii,int>> v[3];
bool comp(pair<pii,int> a,pair<pii,int> b){
    if (b.fr.sc == a.fr.sc)ret (a.fr.fr < b.fr.fr);
    ret (b.fr.sc < a.fr.sc);
}

main(){
    int n,m,k,t,i,j;
    scan2(n,m)
    scan2(k,t)
    for (i=1;i<=k;++i){
        int x,y,a;
        scan3(x,y,a)
        if (a == 1){
            x += (t%(n*2));
            if (x >= n){
                a=3;
                x = n - (x - n);
            }
            w[i] = 1;
        }
        else if (a == 2){
            y += (t%(m*2));
            if (y >= m){
                a = 4;
                y = m-(y - m);
            }
            w[i]=2;
        }
        else if (a == 3){
            x -= (t%(n*2));
            if (x <= 0){
                a=1;
                x = n - (x + n);
            }
            w[i]=1;
        }
        else if (a == 4){
            y -= (t%(m*2));
            if (y <= 0){
                y = m - (m + y);
                a = 2;
            }
            w[i]=2;
        }
        v[w[i]].pb({{x,y},a});
    }
    sort(all(v[1]));
    sort(all(v[2]),comp);

    for (i=1;i<=k;++i){
        cout <<v[w[i]][0].fr.fr<<" ";
        cout <<v[w[i]][0].fr.sc<<" ";
        cout <<v[w[i]][0].sc<<"\n";
        v[w[i]].pop_front();
    }

}

Compilation message

ants.cpp:27:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   27 | main(){
      |      ^
ants.cpp: In function 'int main()':
ants.cpp:28:19: warning: unused variable 'j' [-Wunused-variable]
   28 |     int n,m,k,t,i,j;
      |                   ^
ants.cpp:12:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
ants.cpp:29:5: note: in expansion of macro 'scan2'
   29 |     scan2(n,m)
      |     ^~~~~
ants.cpp:12:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
ants.cpp:30:5: note: in expansion of macro 'scan2'
   30 |     scan2(k,t)
      |     ^~~~~
ants.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 | #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
ants.cpp:33:9: note: in expansion of macro 'scan3'
   33 |         scan3(x,y,a)
      |         ^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -