Submission #340224

# Submission time Handle Problem Language Result Execution time Memory
340224 2020-12-27T10:29:22 Z beksultan04 Ants (IZhO12_ants) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define ll long long
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&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 = 2e5+12,INF=1e9+7;

vector <pair<pii,pii> > v[3];
pair <pii,int> ans[N];
main(){
    int w,h,t,k,i,j;
    scan2(w,h)
    scan2(k,t)
    vector <int> dd,d;
    h++;
    w++;
    int tw = (t%(w*2));
    int th = (t%(h*2));
    h--;
    w--;
    for (i=1;i<=k;++i){
        int a,b,c;
        scan3(a,b,c)
        if (c%2){
            dd.pb(i);
            v[1].pb({{a,b},{c,i}});
        }
        else {
            d.pb(i);
            v[2].pb({{a,b},{c,i}});
        }
    }
    while (tw--){
        for (i=0;i<v[1].size();++i){
            if (v[1][i].sc.fr == 1){
                v[1][i].fr.fr++;
                if (v[1][i].fr.fr == w){
                    v[1][i].sc.fr = 3;
                }
            }
            else {
                v[1][i].fr.fr--;
                if (v[1][i].fr.fr == 0){
                    v[1][i].sc.fr = 1;
                }
            }
        }
    }
    sort(all(v[1]));
    for (i=0;i<v[1].size();++i){
        ans[dd[i]] = {{v[1][i].fr.fr,v[1][i].fr.sc},v[1][i].sc.fr};
    }
    while (th--){
        for (i=0;i<v[2].size();++i){
            if (v[2][i].sc.fr == 2){
                v[2][i].fr.sc++;
                if (v[2][i].fr.sc == h){
                    v[2][i].sc.fr = 4;
                }
            }
            else {
                v[2][i].fr.sc--;
                if (v[2][i].fr.sc == 0){
                    v[2][i].sc.fr = 2;
                }
            }
        }
    }
    sort(all(v[2]));
    for (i=0;i<v[2].size();++i){
        ans[d[i]] = {{v[2][i].fr.fr,v[2][i].fr.sc},v[2][i].sc.fr};
    }
    for (i=1;i<=k;++i){
        cout <<ans[i].fr.fr<<" "<<ans[i].fr.sc<<" "<<ans[i].sc<<"\n";
    }
}

Compilation message

ants.cpp:23:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   23 | main(){
      |      ^
ants.cpp: In function 'int main()':
ants.cpp:47:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for (i=0;i<v[1].size();++i){
      |                  ~^~~~~~~~~~~~
ants.cpp:63:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for (i=0;i<v[1].size();++i){
      |              ~^~~~~~~~~~~~
ants.cpp:67:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |         for (i=0;i<v[2].size();++i){
      |                  ~^~~~~~~~~~~~
ants.cpp:83:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |     for (i=0;i<v[2].size();++i){
      |              ~^~~~~~~~~~~~
ants.cpp:24:19: warning: unused variable 'j' [-Wunused-variable]
   24 |     int w,h,t,k,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("%d %d",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~
ants.cpp:25:5: note: in expansion of macro 'scan2'
   25 |     scan2(w,h)
      |     ^~~~~
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("%d %d",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~
ants.cpp:26:5: note: in expansion of macro 'scan2'
   26 |     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("%d %d %d",&a,&b,&c);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~
ants.cpp:36:9: note: in expansion of macro 'scan3'
   36 |         scan3(a,b,c)
      |         ^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -