제출 #340252

#제출 시각아이디문제언어결과실행 시간메모리
340252beksultan04움직이는 개미 (IZhO12_ants)C++14
0 / 100
160 ms262148 KiB
#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,int> > v[3]; pair <pii,int> ans[N]; deque <int> col[N],row[N]; bool comp(pair <pii,int> a,pair <pii,int> b){ if (a.fr.sc == b.fr.sc){ if (a.fr.fr==b.fr.fr) ret a.sc>b.sc; else ret a.fr.fr<b.fr.fr; } ret a.fr.sc<b.fr.sc; } bool cmp(pair <pii,int> a,pair <pii,int> b){ if (a.fr.fr == b.fr.fr){ if (a.fr.sc==b.fr.sc) ret a.sc>b.sc; else ret a.fr.sc<b.fr.sc; } ret a.fr.fr<b.fr.fr; } main(){ int w,h,t,k,i,j; scan2(w,h) scan2(k,t) vector <int> dd,d; int tw = (t%(w*2)); int th = (t%(h*2)); for (i=1;i<=k;++i){ int a,b,c; scan3(a,b,c) if (c%2){ row[b].pb(i); v[1].pb({{a,b},c}); } else { col[a].pb(i); v[2].pb({{a,b},c}); } } while (tw--){ for (i=0;i<v[1].size();++i){ if (v[1][i].sc == 1){ v[1][i].fr.fr++; if (v[1][i].fr.fr == w){ v[1][i].sc = 3; } } else { v[1][i].fr.fr--; if (v[1][i].fr.fr == 0){ v[1][i].sc = 1; } } } } sort(all(v[1]),cmp); for (i=0;i<v[1].size();++i){ int x = v[1][i].fr.sc; int j = row[x][0]; row[x].pop_front(); ans[j] = {{v[1][i].fr.fr,v[1][i].fr.sc},v[1][i].sc}; } while (th--){ for (i=0;i<v[2].size();++i){ if (v[2][i].sc == 2){ v[2][i].fr.sc++; if (v[2][i].fr.sc == h){ v[2][i].sc = 4; } } else { v[2][i].fr.sc--; if (v[2][i].fr.sc == 0){ v[2][i].sc = 2; } } } } sort(all(v[2]),comp); for (i=0;i<v[2].size();++i){ int x = v[2][i].fr.fr; int j = col[x].front(); col[x].pop_front(); ans[j] = {{v[2][i].fr.fr,v[2][i].fr.sc},v[2][i].sc}; } for (i=1;i<=k;++i){ cout <<ans[i].fr.fr<<" "<<ans[i].fr.sc<<" "<<ans[i].sc<<"\n"; } }

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

ants.cpp:43:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   43 | main(){
      |      ^
ants.cpp: In function 'int main()':
ants.cpp:63:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |         for (i=0;i<v[1].size();++i){
      |                  ~^~~~~~~~~~~~
ants.cpp:79:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |     for (i=0;i<v[1].size();++i){
      |              ~^~~~~~~~~~~~
ants.cpp:86:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |         for (i=0;i<v[2].size();++i){
      |                  ~^~~~~~~~~~~~
ants.cpp:102:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  102 |     for (i=0;i<v[2].size();++i){
      |              ~^~~~~~~~~~~~
ants.cpp:44:19: warning: unused variable 'j' [-Wunused-variable]
   44 |     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:45:5: note: in expansion of macro 'scan2'
   45 |     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:46:5: note: in expansion of macro 'scan2'
   46 |     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:52:9: note: in expansion of macro 'scan3'
   52 |         scan3(a,b,c)
      |         ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...