제출 #1150196

#제출 시각아이디문제언어결과실행 시간메모리
1150196nguynJOIRIS (JOI16_joiris)C++20
0 / 100
1 ms320 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define F first #define S second #define pb push_back #define pii pair<int,int> const int N = 2e5 + 5; int n, k, a[55]; vector<pii> vec; void vertical(int i) { a[i] += k; vec.pb({1, i}); } void horizontal(int i) { for (int j = i; j <= i + k - 1; j++) { a[j]++; } vec.pb({2, i}); } int query(int i) { int mx = *max_element(a + i, a + i + k) + k; for (int j = 1; j < i; j++) { while(a[j] < mx) vertical(j); } for (int j = i + k; j <= n; j++) { while(a[j] < mx) vertical(j); } horizontal(i); } signed main(){ ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ; if (fopen("INP.INP" ,"r")) { freopen("INP.INP" ,"r" , stdin) ; freopen("OUT.OUT" , "w" , stdout) ; } cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n - k + 1; i++) { while((a[i] - a[1]) % k) query(i); } for (int i = n - k + 1; i >= 1; i--) { while((a[i + k - 1] - a[n]) % k) query(i); } int mx = *max_element(a + 1, a + n + 1); for (int i = 1; i <= n; i++) { while(a[i] < mx) { vertical(i); } if (a[i] != mx) { cout << -1; return 0; } } cout << vec.size() << '\n'; for (auto it : vec) { cout << it.F << ' ' << it.S << '\n'; } }

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

joiris.cpp: In function 'int query(int)':
joiris.cpp:36:1: warning: no return statement in function returning non-void [-Wreturn-type]
   36 | }
      | ^
joiris.cpp: In function 'int main()':
joiris.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         freopen("INP.INP" ,"r" , stdin) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
joiris.cpp:43:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |         freopen("OUT.OUT" , "w" , stdout) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...